SENA HD132x Series User Manual

Page 44

Advertising
background image

HD132x Series User Manual

44

while (1) {

//------------------------------------------------------------

// accept an incoming connection attempt on the server socket

//------------------------------------------------------------

sockClient = accept(sock,(LPSOCKADDR)&addrClient,&clientLen);

if (sockClient == INVALID_SOCKET) {

printf("\naccept error???\n");

printf("\nPlease, try later(press ENTER)");

scanf("%c", &chDumm);

break;

} else {

printf("Connected from client[%d.%d.%d.%d]\n"

,addrClient.sin_addr.S_un.S_un_b.s_b1

,addrClient.sin_addr.S_un.S_un_b.s_b2

,addrClient.sin_addr.S_un.S_un_b.s_b3

,addrClient.sin_addr.S_un.S_un_b.s_b4);

//---------------------------------------------------------

// receives data from the client socket(HD1320)

//---------------------------------------------------------

if(ProcessRecv()) { // Exit Program

break;

} else { // Continue Listen

// Just close the client socket

TCPSocketClose(CLOSE_CLIENT_SOCKET);

memset((char*) &addrClient, 0, sizeof(addrClient));

}

}

}

}

//----------------------------------------------

// Process receive : socket recv function called

// return 9 : exit program

// 0 : continue listening

//----------------------------------------------

int ProcessRecv()

Advertising