/***************************************************************************** POPular -- A POP3 server and proxy for large mail systems $Id: net.c,v 1.5 2001/05/02 12:08:07 sqrt Exp $ http://www.remote.org/jochen/mail/popular/ ****************************************************************************** Copyright (C) 1999-2001 Jochen Topf This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA *****************************************************************************/ #if HAVE_CONFIG_H # include #endif #include "popular.h" /***************************************************************************** net_open_udp_socket() *****************************************************************************/ int net_open_udp_socket(const struct sockaddr_in *host, int port) { struct sockaddr_in sa; int s; if ((s = socket(AF_INET, SOCK_DGRAM, 0)) < 0) { /* XLOG-DOC:SOS:0100:socket_call_failed * The creation of a UDP socket to talk to the pcheckd on a backend * failed. */ xlog_printf(xlog_sos, 0x0100, "socket_call_failed errno=%d errmsg='%s'", errno, strerror(errno)); return -1; } memcpy(&sa, host, sizeof(sa)); sa.sin_port = htons(port); if (connect(s, (struct sockaddr *) &sa, sizeof(sa)) < 0) { /* XLOG-DOC:SOS:0101:connect_failed * The connect() call on the UDP socket to the pcheckd on a backend * failed. */ xlog_printf(xlog_sos, 0x0101, "connect_failed backend=%s errno=%d errmsg='%s'", print_ip(host, NULL), errno, strerror(errno)); return -1; } return s; } /** THE END *****************************************************************/