X-Git-Url: https://git.ucc.asn.au/?a=blobdiff_plain;f=Tools%2FNetTest%2Ftcpserver.c;h=5e4aa7277c61ced5404670dac968d1272a0f664e;hb=07e446727e54a17327b53928ce8582ba10eec619;hp=d38b442f894f52040a05fc8c09fdeef2d4c8afaf;hpb=d2f1a4c62225533351551870cbe44d94a4ec4fab;p=tpg%2Facess2.git diff --git a/Tools/NetTest/tcpserver.c b/Tools/NetTest/tcpserver.c index d38b442f..5e4aa727 100644 --- a/Tools/NetTest/tcpserver.c +++ b/Tools/NetTest/tcpserver.c @@ -5,6 +5,7 @@ * tcpserver.c * - TCP Client tester */ +#define DEBUG 1 #include #include #include @@ -45,10 +46,9 @@ void NetTest_TCPServer_Close(tNetTest_TCPServer *Srv) int NetTest_TCPServer_FillSelect(tNetTest_TCPServer *Srv, fd_set *fds) { - ASSERT(Srv->ServerFD >= 0); int max = -1; - if( Srv->nClients == MAX_CLIENTS ) { + if( Srv->nClients < MAX_CLIENTS ) { max = Srv->ServerFD; FD_SET(Srv->ServerFD, fds); } @@ -63,12 +63,21 @@ int NetTest_TCPServer_FillSelect(tNetTest_TCPServer *Srv, fd_set *fds) void NetTest_TCPServer_HandleSelect(tNetTest_TCPServer *Srv, const fd_set *rfds, const fd_set *wfds, const fd_set *efds) { + LOG("Srv=%p", Srv); if( FD_ISSET(Srv->ServerFD, rfds) ) { // New connection! ASSERT(Srv->nClients != MAX_CLIENTS); struct sClient *client = &Srv->Clients[Srv->nClients++]; + LOG("Child?"); client->FD = VFS_OpenChild(Srv->ServerFD, "", VFS_OPENFLAG_READ|VFS_OPENFLAG_WRITE); + LOG("client->FD = %i", client->FD); + } + if( FD_ISSET(Srv->ServerFD, efds) ) + { + LOG("Oops, error on server"); + VFS_Close(Srv->ServerFD); + Srv->ServerFD = -1; } for( int i = 0; i < Srv->nClients; i ++ ) @@ -77,6 +86,11 @@ void NetTest_TCPServer_HandleSelect(tNetTest_TCPServer *Srv, const fd_set *rfds, if( FD_ISSET(client->FD, rfds) ) { // RX'd data on client + // TODO: Cache until '.' is seen, and send all data before+incl that character + char buf[1024]; + size_t len = VFS_Read(client->FD, sizeof(buf), buf); + Debug_HexDump("TCP Srv Rx", buf, len); + VFS_Write(client->FD, len, buf); } if( FD_ISSET(client->FD, efds) )