ws-axis-cvs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dami...@apache.org
Subject svn commit: r371799 - /webservices/axis2/trunk/c/test/core/clientapi/client.c
Date Tue, 24 Jan 2006 04:10:43 GMT
Author: damitha
Date: Mon Jan 23 20:10:40 2006
New Revision: 371799

URL: http://svn.apache.org/viewcvs?rev=371799&view=rev
Log:
added write_to_socket function

Modified:
    webservices/axis2/trunk/c/test/core/clientapi/client.c

Modified: webservices/axis2/trunk/c/test/core/clientapi/client.c
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/c/test/core/clientapi/client.c?rev=371799&r1=371798&r2=371799&view=diff
==============================================================================
--- webservices/axis2/trunk/c/test/core/clientapi/client.c (original)
+++ webservices/axis2/trunk/c/test/core/clientapi/client.c Mon Jan 23 20:10:40 2006
@@ -16,6 +16,16 @@
 
 int main(int argc, char *argv[])
 {
+    if (argc < 3) {
+       fprintf(stderr,"usage %s hostname port\n", argv[0]);
+       exit(0);
+    }
+	write_to_socket(argv[1], argv[2]);
+    return 0;
+}
+
+int write_to_socket(char *address, char* port)
+{
     int sockfd, portno, n, i;
     struct sockaddr_in serv_addr;
     struct hostent *server;
@@ -23,16 +33,12 @@
 
 
     char *buffer;
-    if (argc < 3) {
-       fprintf(stderr,"usage %s hostname port\n", argv[0]);
-       exit(0);
-    }
 
-    portno = atoi(argv[2]);
+	portno = atoi(port);
     sockfd = socket(AF_INET, SOCK_STREAM, 0);
     if (sockfd < 0) 
         error("ERROR opening socket");
-    server = gethostbyname(argv[1]);
+    server = gethostbyname(address);
     if (server == NULL) {
         fprintf(stderr,"ERROR, no such host\n");
         exit(0);
@@ -69,11 +75,10 @@
 
 /*    bzero(buffer,2000);*/
     buffer = '\0';
-    n = read(sockfd,buffer,BUFSIZ);
-    printf("%s\n", buffer);
+	
+    while((n = read(sockfd,buffer,BUFSIZ)) > 0)
+    		printf("%s\n", buffer);
     if (n < 0) 
          error("ERROR reading from socket");
     printf("%s\n",buffer);
-
-    return 0;
 }



Mime
View raw message