Customized
Dependents: MurataTypeYD_RPC_Sample
Fork of SNICInterface_mod by
Diff: Socket/TCPSocketServer.cpp
- Revision:
- 48:e3a26a484d1c
- Parent:
- 43:d80bbb12ffe6
- Child:
- 49:5a5cae02bdf0
--- a/Socket/TCPSocketServer.cpp Fri Jan 23 09:56:01 2015 +0000 +++ b/Socket/TCPSocketServer.cpp Tue Jan 27 07:25:21 2015 +0000 @@ -161,21 +161,38 @@ C_SNIC_Core *snic_core_p = C_SNIC_Core::getInstance(); int i; int ret = -1; + bool accepted = false; C_SNIC_Core::tagCONNECT_INFO_T *con_info_p; - for( i = 0; i < MAX_SOCKET_ID+1; i++ ) - { - // Get connection information - con_info_p = snic_core_p->getConnectInfo( i ); - if( (con_info_p->is_connected == true) - && (con_info_p->is_accept == true) - && (con_info_p->parent_socket == mSocketID) ) + + do + { + for( i = 0; i < MAX_SOCKET_ID+1; i++ ) { - // Set socket id - connection->setAcceptSocket( i ); - ret = 0; - } - } + // Get connection information + con_info_p = snic_core_p->getConnectInfo( i ); + if( (con_info_p->is_connected == true) + && (con_info_p->is_accept == true) + && (con_info_p->parent_socket == mSocketID) ) + { + // Set socket id + connection->setAcceptSocket( i ); + ret = 0; + accepted = true; + break; + } + } + }while( accepted == false ); + con_info_p->is_accept = false; + + char remote_addr[ 20 ] = {'\0'}; + sprintf( remote_addr, "%d.%d.%d.%d" + , (con_info_p->from_ip >> 24 ) & 0xff + , (con_info_p->from_ip >> 16 ) & 0xff + , (con_info_p->from_ip >> 8 ) & 0xff + , con_info_p->from_ip & 0xff ); + + connection->set_address( remote_addr, (int)con_info_p->from_port ); return ret; }