/********************************************************************************************************* "Ensemble" is the proprietary property of The Regents of the University of California ("The Regents.") Copyright (c) 2005-10 The Regents of the University of California, Davis campus. All Rights Reserved. Redistribution and use in source and binary forms, with or without modification, are permitted by nonprofit, research institutions for research use only, provided the conditions in the included license agreement are met. Refer to the file "ensemble_license.txt" for the license agreement, located in the top level directory of this distribution. **********************************************************************************************************/ /* * A simple client that can be used to test communications with matrpc * */ #include #include #include #include #include #include #include #include #include #include #include #include #define SOCKET short int main( int argc, char *argv[] ) { if( argc < 3 ) { printf( "client \n\n" ); exit(1); } SOCKET sock; char* listenIPAddress = argv[1]; printf("%s",listenIPAddress); int listenPort = atoi( argv[2] ); int res, x; struct sockaddr_in serverInfo; serverInfo.sin_family = AF_INET; serverInfo.sin_addr.s_addr = inet_addr( listenIPAddress ); serverInfo.sin_port = htons(listenPort); char buf[512]; sock = socket( AF_INET, SOCK_STREAM, 0 ); res = connect(sock,(struct sockaddr *)&serverInfo,sizeof(serverInfo)); char resBuf[512]; printf( "cmd> " ); char tempBuf[ 256 ]; scanf( "%s", tempBuf ); /* if( !strncmp( tempBuf, "exit", 4 ) || !strncmp( tempBuf, "quit", 4 ) ) { break; } */ sprintf( buf, "1121|%s", tempBuf ); printf( "send -->%s<--\n", buf ); res = send( sock, buf, strlen(buf)+1, 0 ); printf( "Sent %d bytes to matrpc\n", res ); res = recv( sock, resBuf, 512, 0 ); printf( "Received %d bytes from matrpc\n", res ); resBuf[res] = '\0'; printf( "received -->%s<--\n", resBuf ); close(sock); return(0); }