client(0),
is_tcp(false),
is_server(false),
- first_read(false)
+ first_read(false),
+ timeout(0)
{
if (!init)
{
- netInit();
+ netInit(NULL, NULL); // plib-1.4.2 compatible
init = true;
}
if (result > 0)
{
- result = sock.recv( buf, length );
+ if (is_tcp && is_server)
+ {
+ result = client->recv( buf, length );
+ }
+ else
+ {
+ result = sock.recv( buf, length );
+ }
if ( result != length )
{
// read a chunk, keep in the save buffer until we have the
// requested amount read
- if (is_tcp)
+ if (is_tcp && is_server)
{
char *buf_ptr = save_buf + save_len;
result = client->recv( buf_ptr, SG_IO_MAX_MSG_SIZE - save_len );
netSocket* writers[1];
writers[0] = 0;
- int result = netSocket::select( readers, writers, 0 );
+ int result = netSocket::select( readers, writers, timeout );
if (result > 0 && is_server && client == 0)
{