]> code.citadel.org Git - citadel.git/blobdiff - citadel/clientsocket.c
* Removed the 'protocol' parameter from the sock_connect() function. All we have...
[citadel.git] / citadel / clientsocket.c
index 04e94d8707f9e1cc4a364b6b84d5c0a0afbb6af9..67414f93a56ee76bcdd21acdb7fe4ee07a0ee6ba 100644 (file)
@@ -54,7 +54,7 @@
 #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;
@@ -67,13 +67,11 @@ int sock_connect(char *host, char *service, char *protocol)
                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) {
@@ -89,16 +87,11 @@ int sock_connect(char *host, char *service, char *protocol)
                        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) {
@@ -152,7 +145,7 @@ int socket_read_blob(int *Socket,
                     int bytes, 
                     int timeout)
 {
-       CitContext *CCC=CC;
+       CitContext *CCC = MyContext();
        const char *Error;
        int retval = 0;
 
@@ -177,7 +170,7 @@ int socket_read_blob(int *Socket,
 
 int sock_read_to(int *sock, char *buf, int bytes, int timeout, int keep_reading_until_full)
 {
-       CitContext *CCC=CC;
+       CitContext *CCC = MyContext();
        int rc;
 
        FlushStrBuf(CCC->MigrateBuf);
@@ -206,10 +199,11 @@ int sock_read_to(int *sock, char *buf, int bytes, int timeout, int keep_reading_
 
 int CtdlSockGetLine(int *sock, StrBuf *Target)
 {
-       CitContext *CCC=CC;
+       CitContext *CCC = MyContext();
        const char *Error;
        int rc;
 
+       FlushStrBuf(Target);
        rc = StrBufTCP_read_buffered_line_fast(Target, 
                                               CCC->sReadBuf,
                                               &CCC->sPos,
@@ -234,7 +228,7 @@ int CtdlSockGetLine(int *sock, StrBuf *Target)
 int sock_getln(int *sock, char *buf, int bufsize)
 {
        int i, retval;
-       CitContext *CCC=CC;
+       CitContext *CCC = MyContext();
        const char *pCh;
 
        FlushStrBuf(CCC->sMigrateBuf);