From 148a9745ec25dbc785f51f83a5a3bf5c8501432e Mon Sep 17 00:00:00 2001 From: tzachid Date: Mon, 19 Dec 2005 09:02:08 +0000 Subject: [PATCH] [SDP] Moved the test program to be built in the tests directory. (Rev 818) git-svn-id: svn://openib.tc.cornell.edu/gen1@206 ad392aa1-c5ef-ae45-8dd8-e69d62a5ef86 --- trunk/ulp/sdp/tests/basic/BasicConnect.cpp | 492 ++++++++++++++++++ trunk/ulp/sdp/tests/basic/SdpConnect.cpp | 550 +++++++++++++++++++++ trunk/ulp/sdp/tests/basic/makefile | 7 + trunk/ulp/sdp/tests/basic/sources | 91 ++++ trunk/ulp/sdp/tests/dirs | 3 + 5 files changed, 1143 insertions(+) create mode 100644 trunk/ulp/sdp/tests/basic/BasicConnect.cpp create mode 100644 trunk/ulp/sdp/tests/basic/SdpConnect.cpp create mode 100644 trunk/ulp/sdp/tests/basic/makefile create mode 100644 trunk/ulp/sdp/tests/basic/sources create mode 100644 trunk/ulp/sdp/tests/dirs diff --git a/trunk/ulp/sdp/tests/basic/BasicConnect.cpp b/trunk/ulp/sdp/tests/basic/BasicConnect.cpp new file mode 100644 index 00000000..9f5837a9 --- /dev/null +++ b/trunk/ulp/sdp/tests/basic/BasicConnect.cpp @@ -0,0 +1,492 @@ +#include +#include +#include +#include +#include +#include +#include +#include +#include + + +static int result = 0; + + +// Notes: +// +// -- Maximum message size calculation: +// The maximum lenght of an IP message is 64K-1 (the length field in the IP header is 16 bits wide). +// The IP length field includes the IP header. +// Therefore, the maximum length of a UDP message payload is: +// 64K-1-20(IP header)-8(UDP header) = 65507 bytes + + +void printUsage(char *exeName){ + printf("usage of program is:\n"); + printf("%s <\"client\"> \nif contSize==0, then client will send numberOfMessages messages of 1,2,3,...numberOfMessages bytes\nif contSize!=0 then client will send numberOfMessages messages of contSize bytes\n",exeName); + printf("\n or\n\n"); + printf("%s \n\t", exeName); +} + +WSABUF* allocateBuffer(int len){ + WSABUF* buffer = new WSABUF[1]; + if (buffer == NULL) { + printf("Error in allocating memory for buffer\n"); + return NULL; + }else{ + buffer[0].len = len; + buffer[0].buf = new char [len]; + if (buffer[0].buf == NULL) { + printf("Error in allocating memory for buffer[0].buf\n"); + delete [] buffer; + return NULL; + }else{ + buffer[0].buf[0] = 0; + return buffer; + } + } +} + +void freeBuffer(WSABUF* buffer){ + delete [] buffer[0].buf; + delete [] buffer; +} + +SOCKET createSocket(){ + WSADATA wsaData; + int error = WSAStartup( MAKEWORD( 2, 2 ), &wsaData); + if (error) { + printf("Error in WSAStartup: winsock error=%d\n", WSAGetLastError()); + return INVALID_SOCKET; + } + SOCKET socket = WSASocket(AF_INET, SOCK_STREAM, IPPROTO_TCP, NULL, 0, 0); + if (socket == INVALID_SOCKET) { + printf("Error in WSASocket: winsock error=%d\n", WSAGetLastError()); + } + return socket; +} + +bool increaseSendBuffSize(SOCKET socket, int requestedBufferSize){ + int realSendBufferSize; + int error = setsockopt(socket, SOL_SOCKET, SO_SNDBUF, (char*)&requestedBufferSize, sizeof (int)); + if (error) { + printf("Error in setsockopt: winsock error=%d\n", WSAGetLastError()); + return FALSE; + } + int size = sizeof (int); + error = getsockopt(socket, SOL_SOCKET, SO_SNDBUF, (char*)&realSendBufferSize, &size); + if (error) { + printf("Error in getsockopt: winsock error=%d\n", WSAGetLastError()); + return FALSE; + } + if (realSendBufferSize != requestedBufferSize) { + printf("Error: realSendBufferSize!=requestedBufferSize:\n \ + , realSendBufferSize = %d, requestedBufferSize=%d", + realSendBufferSize, requestedBufferSize); + return FALSE; + } + return TRUE; +} + +sockaddr addressFromString(char *address, USHORT port) + +{ + SOCKADDR_IN socket_address; + sockaddr *socket_address_ptr = (sockaddr*)&socket_address; + memset(&socket_address, 0, sizeof(socket_address)); + socket_address.sin_family = AF_INET; + socket_address.sin_port = htons(port); + int b1,b2,b3,b4; + sscanf(address, "%d.%d.%d.%d",&b1, &b2, &b3, &b4); + socket_address.sin_addr.S_un.S_un_b.s_b1 = (BYTE)b1; + socket_address.sin_addr.S_un.S_un_b.s_b2 = (BYTE)b2; + socket_address.sin_addr.S_un.S_un_b.s_b3 = (BYTE)b3; + socket_address.sin_addr.S_un.S_un_b.s_b4 = (BYTE)b4; + return *socket_address_ptr; +} + +void performancePrint(double size, DWORD startTime){ + DWORD mseconds = GetTickCount()-startTime; + if(mseconds!=0){ + printf("sent and received %f bytes/%d mseconds => %f MBPS\n", + size, mseconds, (size/mseconds)/1000.0); + }else{ + printf("sent and received %f bytes, in 0 mseconds\n", size); + } +} + +void clientDebugMessage(bool printEnable, int debugMessageNumber, double size, DWORD time){ + if(!printEnable){ + return; + } + switch(debugMessageNumber){ + case 1: + printf("sending %f bytes at time %d msec\n", size, time); + break; + case 2: + performancePrint(size, time); + break; + case 3: + printf("\n\n\nPerformance summary:\n"); + performancePrint(size, time); + break; + default: + break; + } +} + +// 0: normanl good receive +// 2: error +int myReceive( + SOCKET socket, + WSABUF* receiveBufferArray, + WSAOVERLAPPED* wsaoverlappedPtr, + DWORD* numOfRecvBytesPtr, + DWORD* flagsPtr, + int timeoutTime + ){ + + int recvStat = WSARecv( + socket, + receiveBufferArray, + 1, + numOfRecvBytesPtr, + flagsPtr, + NULL, + NULL + ); + if( (recvStat!= 0) ){ + printf("erroro\n"); + DWORD dwgle = WSAGetLastError(); + if (dwgle != WSA_IO_PENDING ) { + printf("Error in WSARecv: winsock error=%d\n", WSAGetLastError()); + return 2; + } + } + return 0; +} + + +#define SEND + +void client(char *IP, int Port, int numberOfMessages, int constSize) +{ + bool debug = FALSE; + SOCKET socket = INVALID_SOCKET; + sockaddr localSockAddr; + sockaddr destSockAddr; + WSABUF* sendBufferArray = NULL; + WSABUF* receiveBufferArray = NULL; + DWORD firstSendStartTime; + DWORD startTime; + DWORD flags = 0; + DWORD numOfSentBytes; + DWORD numOfRecvBytes; + double totalSentBytes = 0; + DWORD timeoutTime = 3000; //represents mseconds + DWORD totalWaitTime = 0; + int ret; + + + printf("client starting: ip=%s, port=%d, numberOfMessages=%d\n", IP, Port, numberOfMessages ); + + // open and connect the socket: + socket = createSocket(); + if(socket==INVALID_SOCKET) { + result = 1; + goto cleanup; + } + + destSockAddr = addressFromString (IP, (USHORT)Port); + if(WSAConnect(socket, &destSockAddr, sizeof(destSockAddr), NULL, NULL, NULL, NULL)!=0){ + printf("Error in WSAConnect: winsock error=%d\n", WSAGetLastError()); + result = 1; + goto cleanup; + } + + +#ifndef SEND + // Send the buffer sizes + char message[40]; + StringCbPrintf(message, sizeof message, "%d,%d,", constSize,numberOfMessages); + ret = send(socket, message, strlen (message), 0); + if (ret != strlen (message)) { + printf("Error in send winsock error=%d\n", WSAGetLastError()); + result = 1; + goto cleanup; + } +#endif + + // allocate send & receive buffers: + sendBufferArray = allocateBuffer(constSize); + if(sendBufferArray==NULL){ + result = 1; + goto cleanup; + } + receiveBufferArray = allocateBuffer(constSize); + if(receiveBufferArray==NULL){ + result = 1; + goto cleanup; + } + + firstSendStartTime = GetTickCount(); + // main client loop: + for(int i = 0; i < numberOfMessages; i++) { + int messageSize = constSize==0 ? i : constSize; + startTime = GetTickCount(); + clientDebugMessage(debug, 1, (double)messageSize, startTime); + sendBufferArray[0].len = messageSize; + if(i==numberOfMessages){ + sendBufferArray[0].buf[0] = 1; + } + + if (messageSize > 10 ) { + // Just put some data in here + int q; + for (q= 0; q< 8; q++ ) { + sendBufferArray[0].buf[q] = (char)q + 'A'; + } + } +#ifdef SEND + if(WSASend(socket, sendBufferArray, 1, &numOfSentBytes, 0, NULL, NULL) != 0) { + printf("Error in WSASend in messageSize=%d: winsock error=%d\n", messageSize, WSAGetLastError()); + result = 1; + goto cleanup; + } + if(numOfSentBytes!=messageSize) { + printf("numOfSentBytes!=messageSize\n"); + result = 1; + goto cleanup; + } +#else + DWORD Flags = 0; + if(WSARecv(socket, sendBufferArray, 1, &numOfSentBytes, &Flags, NULL, NULL) != 0) { + printf("Error in WSARecv in messageSize=%d: winsock error=%d\n", messageSize, WSAGetLastError()); + result = 1; + goto cleanup; + } + assert(numOfSentBytes == messageSize); // Make sure we have a complete buffer + if (numOfSentBytes > 4) { + //printf("Recieved %c%c%c%c\n", sendBufferArray->buf[0], sendBufferArray->buf[1], sendBufferArray->buf[2], sendBufferArray->buf[3] ); + } + //printf("i = %d Recieved %d bytes\n",i, numOfSentBytes); + +#endif +/* + int recvStatus = myReceive( + socket, + receiveBufferArray, + NULL, + &numOfRecvBytes, + &flags, + timeoutTime + ); + switch(recvStatus){ + case 0: + totalSentBytes+=messageSize; + if(numOfRecvBytes!=messageSize){ + printf("numOfRecvBytes(%d) != messageSize(%d)\n", numOfRecvBytes, messageSize); + result = 1; + goto cleanup; + } + clientDebugMessage(debug, 2, messageSize, startTime); + break; + case 2: + result = 1; + goto cleanup; + default: + printf("reached default in switch statement\n"); + result = 1; + goto cleanup; + } +*/ + } + + if(totalSentBytes!=0){ + clientDebugMessage(TRUE, 3, totalSentBytes, firstSendStartTime+totalWaitTime); + }else{ + printf("no bytes transferred\n"); + } + + cleanup: + if(socket!=INVALID_SOCKET){ + if(closesocket(socket)!=0){ + printf("closesocket error: error = %d\n", WSAGetLastError()); + } + } + WSACleanup(); + if(sendBufferArray!=NULL){ + freeBuffer(sendBufferArray); + } + if(receiveBufferArray!=NULL){ + freeBuffer(receiveBufferArray); + } +// printf("sleeping ...\n"); +// Sleep(1000); +} + +void serverDebugMessage(bool printEnable, int messageNumber, double size){ + if(!printEnable){ + return; + } + switch(messageNumber){ + case 1: + printf("-----------------------------------------------------------\n"); + printf(" received %f bytes at time %d\n", size, GetTickCount()); + break; + case 2: + printf("sent back %f bytes at time %d\n", size, GetTickCount()); + printf("-----------------------------------------------------------\n\n"); + break; + default: + break; + } +} + +void Server(int Port) +{ + SOCKET s; + WSADATA wsaData; + sockaddr saLocal, saFrom; + int i; + DWORD start, end, Flags = 0; + int NumberOfMessages = 1; + int MessageSize = 70000; + WSABUF wsb; + + + printf("Starting as Server port=%d, \n", Port ); + + int err = WSAStartup( MAKEWORD( 2, 2 ), &wsaData); + if ( err != 0 ) { + printf("Error opening winsock err=%d", WSAGetLastError()); + goto cleanup; + } + + s = WSASocket(AF_INET, SOCK_STREAM, IPPROTO_TCP, NULL, 0, 0 ); + if (s == INVALID_SOCKET) { + printf("Error creating socket winsock err=%d", WSAGetLastError()); + goto cleanup; + } + + int RecvBufferSize = 0* 1024, RealRecvBufferSize; + err = setsockopt(s, SOL_SOCKET, SO_RCVBUF, (char *)&RecvBufferSize, sizeof (int)); + if ( err != 0 ) { + printf("Error setsockopt failed err=%d", WSAGetLastError()); + goto cleanup; + } + int Size = sizeof (int); + err = getsockopt(s, SOL_SOCKET, SO_RCVBUF, (char *)&RealRecvBufferSize, &Size); + if ( err != 0 ) { + printf("Error setsockopt failed err=%d", WSAGetLastError()); + goto cleanup; + } + if (RealRecvBufferSize != RecvBufferSize) { + printf("Error: RealSendBufferSize = %d", RealRecvBufferSize); + goto cleanup; + } + + + DWORD dwBytesRecieved; + + // Bind the socket first + + SOCKADDR_IN *psa = (SOCKADDR_IN*)&saLocal; + memset(&saLocal, 0, sizeof(saLocal)); + psa->sin_family = AF_INET; + psa->sin_port = htons((USHORT)Port); + + err = bind(s, &saLocal, sizeof(saLocal)); + if ( err != 0 ) { + printf("Error bind winsock err=%d", WSAGetLastError()); + goto cleanup; + } + + err = listen(s, 10); + if ( err != 0 ) { + printf("Error on listen winsock err=%d", WSAGetLastError()); + goto cleanup; + } + + while (1) { + int addrLen = sizeof (saFrom); + SOCKET s1 = accept(s, &saFrom, &addrLen); + if (s1 == INVALID_SOCKET) { + printf("Error accept failed err=%d", WSAGetLastError()); + goto cleanup; + } + + + for (i =0; i < 1; i++) { + // Recieve the data + printf ("Calling recieve\n"); + + wsb.len = MessageSize; + wsb.buf = new char [MessageSize]; + if (wsb.buf == NULL ) { + printf("Error Allocating memory\n"); + goto cleanup; + } + + err = WSARecv( + s1, + &wsb, + 1, + &dwBytesRecieved, + &Flags, + NULL, + NULL + ); + if (err == SOCKET_ERROR) { + DWORD gle = WSAGetLastError(); + if (gle != WSA_IO_PENDING) { + + printf("Error WSARecv winsock err=%d", gle); + goto cleanup; + } + } + + // send a reply packet + + StringCbCopy(wsb.buf, wsb.len, "I'm a demo server");\ + wsb.len = strlen(wsb.buf); + err = WSASend( + s1, + &wsb, + 1, + &dwBytesRecieved, + Flags, + NULL, + NULL + ); + if (err == SOCKET_ERROR) { + DWORD gle = WSAGetLastError(); + if (gle != WSA_IO_PENDING) { + + printf("Error WSASend winsock err=%d", gle); + goto cleanup; + } + } + } + } + cleanup: + WSACleanup(); + +} + +__cdecl main (int argc, char *argv[]){ + if ((argc == 6) && !_stricmp(argv[1],"client") ) { + int port = atoi(argv[3]); + int numberOfMessages = atoi(argv[4]); + int constSize = atoi(argv[5]); + client(argv[2], port, numberOfMessages, constSize); + return result; + }else if((argc==3 ) && !_stricmp(argv[1],"server") ){ + int port = atoi(argv[2]); + Server(port); + return result; + }else{ + printUsage(argv[0]); + return 1; + } +} diff --git a/trunk/ulp/sdp/tests/basic/SdpConnect.cpp b/trunk/ulp/sdp/tests/basic/SdpConnect.cpp new file mode 100644 index 00000000..c0cdcf6d --- /dev/null +++ b/trunk/ulp/sdp/tests/basic/SdpConnect.cpp @@ -0,0 +1,550 @@ + +#ifdef _WIN32 +#include +#include +#include +#include + +#define AF_INET_FAMILY PF_INET + +#define sleep(x) Sleep(1000 * (x)); +#define CloseSocket closesocket + +#define GetTimeMs() GetTickCount() +#else + +#define AF_INET_FAMILY 27 + +#include +#include +#include +#include +#include + +#define _stricmp strcasecmp +#define WSAGetLastError() errno +#define CloseSocket close + + +#endif +// Windows linux + +const int NumberOfThreads = 1; + +HANDLE g_ComplitionPort; +HANDLE *g_pThreads; + +#define ASSERT assert + +struct sockaddr addressFromString(char *address, int port) +{ + unsigned int b1,b2,b3,b4; + + struct sockaddr_in socket_address; + struct sockaddr *socket_address_ptr = (struct sockaddr*)&socket_address; + + memset(&socket_address, 0, sizeof(socket_address)); + socket_address.sin_family = AF_INET; + socket_address.sin_port = htons((u_short)port); + + + sscanf(address, "%d.%d.%d.%d",&b1, &b2, &b3, &b4); + socket_address.sin_addr.s_addr = b4 * 256 * 256 *256 + + b3 * 256 * 256 + + b2 * 256 + + b1; + + return *socket_address_ptr; +} + + +struct OverlappedSend { + OVERLAPPED Overlapped; + SOCKET Socket; + void *Buffer; // The data to send + int DataSize; + DWORD NumberOfBytesSent; + int RemainingSends; + int SendsInAir; // Curently sent data + CRITICAL_SECTION Lock; + HANDLE SendDoneEvent; + +}; + + +DWORD WINAPI WorkerThreadFunc( LPVOID lpParam ) +{ + BOOL ret; + DWORD NumberOfBytes; + ULONG_PTR CompletionKey; + OVERLAPPED* lpOverlapped; + OverlappedSend *pOverLappedSend; + BOOL ContinueLoop = true; + int iRet; + + while (TRUE) { + ret = GetQueuedCompletionStatus( + g_ComplitionPort, + &NumberOfBytes, + &CompletionKey, + &lpOverlapped, + INFINITE); + ASSERT(ret != 0); + pOverLappedSend = CONTAINING_RECORD(lpOverlapped, OverlappedSend, Overlapped); + // Work on the object itself: + EnterCriticalSection(&pOverLappedSend->Lock); + pOverLappedSend->SendsInAir--; + ASSERT(pOverLappedSend->SendsInAir ==0); // Only one thread + if (pOverLappedSend->RemainingSends > 0) { + // do the next send + WSABUF Buffers; + Buffers.len = pOverLappedSend->DataSize; + Buffers.buf = (char *) pOverLappedSend->Buffer; + pOverLappedSend->SendsInAir++; + pOverLappedSend->RemainingSends--; + + iRet = WSASend( + pOverLappedSend->Socket, + &Buffers, + 1, + &pOverLappedSend->NumberOfBytesSent, + 0, + &pOverLappedSend->Overlapped, + NULL + ); + ASSERT((iRet ==0) || (iRet == SOCKET_ERROR && WSAGetLastError() == WSA_IO_PENDING )); + + } else { + // Nothing more to send - signal compleation and exit + SetEvent(pOverLappedSend->SendDoneEvent); + ContinueLoop = false; + } + LeaveCriticalSection(&pOverLappedSend->Lock); + if (!ContinueLoop) { + break; + } + + } + return 0; +} + +void CreateComplitionPort(int newfd) +{ + g_pThreads = new HANDLE [NumberOfThreads]; + ASSERT(g_pThreads != NULL); + + g_ComplitionPort = CreateIoCompletionPort((HANDLE)newfd, NULL, NULL, 2); + if(g_ComplitionPort == NULL) { + printf("Create complition port failed err=%d", GetLastError()); + exit(1); + } + + // Create the threads that will work on the complitions + g_pThreads[0] = CreateThread(NULL, 0 ,WorkerThreadFunc ,NULL, 0,NULL ); + + +} + +void CloseComplitionPort() +{ + //??? Post a complition thread end message + + WaitForMultipleObjects(NumberOfThreads,g_pThreads, TRUE, INFINITE); + CloseHandle(g_ComplitionPort); + +} + +void SendDataOverlapped(int newfd, double NumberOfBuffers, double BufferSize, BOOL SendPacketNumber) +{ + // We will start with one operations simultaniously + int i ; + double d; + VOID *buffer = NULL; + double elapsed, acc = 0; + WSAOVERLAPPED wsa; + OverlappedSend *pOverLappedSend = NULL; + BOOL ret; + memset(&wsa, 0, sizeof wsa); + + buffer = malloc ((size_t)BufferSize); + if (buffer == NULL) { + printf("Error allocating buffer\n"); + exit(1); + } + + CreateComplitionPort(newfd); + + pOverLappedSend = new OverlappedSend; + + // Set it's fields + memset(&pOverLappedSend->Overlapped, 0, sizeof (pOverLappedSend->Overlapped)); + pOverLappedSend->Socket = newfd; + pOverLappedSend->Buffer = buffer; + pOverLappedSend->DataSize = (size_t)BufferSize; + pOverLappedSend->RemainingSends = (size_t)NumberOfBuffers; + pOverLappedSend->SendsInAir = 1; // To force a simulate of the compleation + InitializeCriticalSection(&pOverLappedSend->Lock); + pOverLappedSend->SendDoneEvent = CreateEvent(NULL, FALSE, FALSE, NULL); + + double Start = GetTimeMs(); + // Post the message that will do the first send + ret = PostQueuedCompletionStatus( + g_ComplitionPort, + (DWORD)BufferSize, + NULL, + &pOverLappedSend->Overlapped + ); + ASSERT(ret != 0); + + // wait for the send + WaitForSingleObject(pOverLappedSend->SendDoneEvent, INFINITE); + elapsed = (GetTimeMs() - Start) / 1000; + printf("Finishd sending correctly %f mbytes/sec\n", NumberOfBuffers * BufferSize /elapsed/1024/1024 ); + CloseComplitionPort(); +//Cleanup: + free(buffer); + + +} + + + +void SendData(int newfd, double NumberOfBuffers, double BufferSize, BOOL SendPacketNumber) +{ + int i ; + double d; + CHAR *buffer = NULL; + double elapsed, acc = 0; + + buffer = new char [(size_t)BufferSize]; + if (buffer == NULL) { + printf("Error allocating buffer\n"); + exit(1); + } + + printf("Starting to send %lf messages of size %lf\n", NumberOfBuffers, BufferSize ); + + i = 0; + + for (i = 0; i < 10; i++) { + buffer[i] = 'a' + i; + } + double Start = GetTimeMs(); + + for (d=0; d < NumberOfBuffers; d++) { + int j; + if (SendPacketNumber) { + memset(buffer, (char) d, (size_t)BufferSize); + } + + j = send(newfd, buffer, (size_t)BufferSize, 0 ); + acc += j; + if (j!=BufferSize) { + printf("Error send not compleated sent %lf\n", acc); + goto Cleanup; + } + } + elapsed = (GetTimeMs() - Start) / 1000; + printf("Finishd sending correctly %f mbytes/sec (%f seconfs)\n", acc/elapsed/1024/1024, elapsed ); +Cleanup: + free(buffer); +} + + +void RecvData(int newfd, double NumberOfBuffers, double BufferSize ) +{ + int read1 = 1; + unsigned char *p; + char buffer[380000]; + double elapsed, acc = 0; + int i; + double Start = GetTimeMs(); + + while ((read1 != -1) /*&& (acc < (double)BufferSize * NumberOfBuffers)*/) { + read1 = recv(newfd, buffer, sizeof buffer, 0); + if (read1 == -1 || read1 == 0) { + printf("Finsihed reading, total read %lf bytes last read =%d\n", acc, read1 ); + if (acc != BufferSize * NumberOfBuffers) { + printf("Error, expected to read %lf but read %lf\n", + (BufferSize * NumberOfBuffers), acc); + } + break; + } + else { + acc += read1; + +// printf("read returned %d \"%c%c%c%c\"\n",read1, +// buffer[0],buffer[1], buffer[2], buffer[3]); + } + } + + if (acc != ((double)BufferSize * NumberOfBuffers)) { + printf("Error, expected to read %lf but read %lf", + ((double)BufferSize * NumberOfBuffers), acc); + } else { + elapsed = (GetTimeMs() - Start) / 1000; + printf("Finishd reading correctly %f mbytes/sec (time = %f)\n", acc / elapsed/1024/1024, elapsed); + } +} + +void PrintUsage(char *name) +{ + printf("The program might be used in client or server mode\n"); + printf("usage is %s \n", name); + printf("usage is %s