#define INADDR_NONE 0xffffffff
#endif
-int sock_connect(char *host, char *service, char *protocol)
+int sock_connect(char *host, char *service)
{
struct hostent *phe;
struct servent *pse;
return(-1);
if ((service == NULL) || IsEmptyStr(service))
return(-1);
- if ((protocol == NULL) || IsEmptyStr(protocol))
- return(-1);
memset(&sin, 0, sizeof(sin));
sin.sin_family = AF_INET;
- pse = getservbyname(service, protocol);
+ pse = getservbyname(service, "tcp");
if (pse) {
sin.sin_port = pse->s_port;
} else if ((sin.sin_port = htons((u_short) atoi(service))) == 0) {
host, strerror(errno));
return(-1);
}
- if ((ppe = getprotobyname(protocol)) == 0) {
- CtdlLogPrintf(CTDL_CRIT, "Can't get %s protocol entry: %s\n",
- protocol, strerror(errno));
+ if ((ppe = getprotobyname("tcp")) == 0) {
+ CtdlLogPrintf(CTDL_CRIT, "Can't get tcp protocol entry: %s\n", strerror(errno));
return(-1);
}
- if (!strcmp(protocol, "udp")) {
- type = SOCK_DGRAM;
- } else {
- type = SOCK_STREAM;
- }
+ type = SOCK_STREAM;
s = socket(PF_INET, type, ppe->p_proto);
if (s < 0) {
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
-int sock_connect(char *host, char *service, char *protocol);
+int sock_connect(char *host, char *service);
int sock_read_to(int *sock, char *buf, int bytes, int timeout, int keep_reading_until_full);
int sock_read(int *sock, char *buf, int bytes, int keep_reading_until_full);
int sock_write(int *sock, const char *buf, int nbytes);
extract_token(hostbuf, buf, 0, ':', sizeof hostbuf);
if (extract_token(portbuf, buf, 1, ':', sizeof portbuf)==-1)
/* Didn't specify a port so we'll try the psuedo-standard 3310 */
- sock = sock_connect(hostbuf, CLAMD_PORT, "tcp");
+ sock = sock_connect(hostbuf, CLAMD_PORT);
else
/* Port specified lets try connecting to it! */
- sock = sock_connect(hostbuf, portbuf, "tcp");
+ sock = sock_connect(hostbuf, portbuf);
if (sock >= 0) CtdlLogPrintf(CTDL_DEBUG, "Connected!\n");
}
extract_token(portbuf, buf, 1, ' ', sizeof portbuf);
/* Attempt to establish connection to STREAM socket */
- streamsock = sock_connect(hostbuf, portbuf, "tcp");
+ streamsock = sock_connect(hostbuf, portbuf);
if (streamsock < 0) {
/* If the service isn't running, just pass the mail
CtdlLogPrintf(CTDL_DEBUG, "network: polling <%s>\n", node);
CtdlLogPrintf(CTDL_NOTICE, "Connecting to <%s> at %s:%s\n", node, host, port);
- sock = sock_connect(host, port, "tcp");
+ sock = sock_connect(host, port);
if (sock < 0) {
CtdlLogPrintf(CTDL_ERR, "Could not connect: %s\n", strerror(errno));
network_talking_to(node, NTT_REMOVE);
if (CtdlThreadCheckStop())
return;
- sock = sock_connect(pop3host, "110", "tcp");
+ sock = sock_connect(pop3host, "110");
if (sock < 0) {
CtdlLogPrintf(CTDL_ERR, "Could not connect: %s\n", strerror(errno));
return;
strcpy(mx_port, "25");
}
CtdlLogPrintf(CTDL_DEBUG, "SMTP client: connecting to %s : %s ...\n", mx_host, mx_port);
- sock = sock_connect(mx_host, mx_port, "tcp");
+ sock = sock_connect(mx_host, mx_port);
snprintf(dsn, SIZ, "Could not connect: %s", strerror(errno));
if (sock >= 0) CtdlLogPrintf(CTDL_DEBUG, "SMTP client: connected!\n");
if (sock < 0) {
for (sa=0; sa<num_sahosts; ++sa) {
extract_token(buf, sahosts, sa, '|', sizeof buf);
CtdlLogPrintf(CTDL_INFO, "Connecting to SpamAssassin at <%s>\n", buf);
- sock = sock_connect(buf, SPAMASSASSIN_PORT, "tcp");
+ sock = sock_connect(buf, SPAMASSASSIN_PORT);
if (sock >= 0) CtdlLogPrintf(CTDL_DEBUG, "Connected!\n");
}