You are viewing a plain text version of this content. The canonical link for it is here.
Posted to axis-cvs@ws.apache.org by da...@apache.org on 2006/01/23 07:34:20 UTC
svn commit: r371472 - /webservices/axis2/trunk/c/test/core/clientapi/client.c
Author: damitha
Date: Sun Jan 22 22:34:16 2006
New Revision: 371472
URL: http://svn.apache.org/viewcvs?rev=371472&view=rev
Log: (empty)
Added:
webservices/axis2/trunk/c/test/core/clientapi/client.c
Added: 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=371472&view=auto
==============================================================================
--- webservices/axis2/trunk/c/test/core/clientapi/client.c (added)
+++ webservices/axis2/trunk/c/test/core/clientapi/client.c Sun Jan 22 22:34:16 2006
@@ -0,0 +1,62 @@
+#include <stdio.h>
+#include <sys/types.h>
+#include <sys/socket.h>
+#include <netinet/in.h>
+#include <netdb.h>
+#include <sys/types.h>
+#include <sys/stat.h>
+
+void error(char *msg)
+{
+ perror(msg);
+ exit(0);
+}
+
+int main(int argc, char *argv[])
+{
+ int sockfd, portno, n, i;
+ struct sockaddr_in serv_addr;
+ struct hostent *server;
+ int fd = open("soap_req", "r");
+
+
+ char buffer[2000];
+ if (argc < 3) {
+ fprintf(stderr,"usage %s hostname port\n", argv[0]);
+ exit(0);
+ }
+
+ portno = atoi(argv[2]);
+ sockfd = socket(AF_INET, SOCK_STREAM, 0);
+ if (sockfd < 0)
+ error("ERROR opening socket");
+ server = gethostbyname(argv[1]);
+ if (server == NULL) {
+ fprintf(stderr,"ERROR, no such host\n");
+ exit(0);
+ }
+ bzero((char *) &serv_addr, sizeof(serv_addr));
+ serv_addr.sin_family = AF_INET;
+ bcopy((char *)server->h_addr,
+ (char *)&serv_addr.sin_addr.s_addr,
+ server->h_length);
+ serv_addr.sin_port = htons(portno);
+ if (connect(sockfd,&serv_addr,sizeof(serv_addr)) < 0)
+ error("ERROR connecting");
+
+ while((i = read(fd, buffer, 1999)) > 0)
+ /* printf("%s\n", buffer);*/
+
+ n = write(sockfd,buffer,strlen(buffer));
+ buffer[0] = '\0';
+ if (n < 0)
+ error("ERROR writing to socket");
+ bzero(buffer,2000);
+ n = read(sockfd,buffer,1999);
+ printf("%s\n", buffer);
+ if (n < 0)
+ error("ERROR reading from socket");
+ printf("%s\n",buffer);
+
+ return 0;
+}