version 1.12, 2005/03/08 00:28:48
|
version 1.14, 2005/03/08 08:57:55
|
|
|
trace ( "select_server (%x): accepting client connection\n", id ); | trace ( "select_server (%x): accepting client connection\n", id ); |
| |
/* accept a single connection */ | /* accept a single connection */ |
tmp = sizeof ( mem->sock[i].peer ); |
tmp = sizeof ( mem->sock[n_connections].peer ); |
mem->sock[i].s = accept ( mem->s, (struct sockaddr*) &mem->sock[i].peer, &tmp ); |
mem->sock[n_connections].s = accept ( mem->s, (struct sockaddr*) &mem->sock[n_connections].peer, &tmp ); |
wsa_ok ( mem->sock[i].s, INVALID_SOCKET !=, "select_server (%lx): accept() failed: %d\n" ); |
wsa_ok ( mem->sock[n_connections].s, INVALID_SOCKET !=, "select_server (%lx): accept() failed: %d\n" ); |
| |
ok ( mem->sock[i].peer.sin_addr.s_addr == inet_addr ( gen->inet_addr ), |
ok ( mem->sock[n_connections].peer.sin_addr.s_addr == inet_addr ( gen->inet_addr ), |
"select_server (%x): strange peer address\n", id ); | "select_server (%x): strange peer address\n", id ); |
| |
/* add to list of open connections */ | /* add to list of open connections */ |
FD_SET ( mem->sock[i].s, &fds_openrecv ); |
FD_SET ( mem->sock[n_connections].s, &fds_openrecv ); |
FD_SET ( mem->sock[i].s, &fds_opensend ); |
FD_SET ( mem->sock[n_connections].s, &fds_opensend ); |
| |
n_connections++; | n_connections++; |
} | } |
|
|
ok ( mem->sock[i].n_recvd <= n_expected, "select_server (%x): received too many bytes: %d\n", id, mem->sock[i].n_recvd ); | ok ( mem->sock[i].n_recvd <= n_expected, "select_server (%x): received too many bytes: %d\n", id, mem->sock[i].n_recvd ); |
} | } |
| |
if ( ( mem->sock[i].n_sent < n_expected ) && FD_ISSET ( mem->sock[i].s, &fds_send ) ) { |
if ( ( mem->sock[i].n_sent < n_expected ) && ( mem->sock[i].n_recvd == n_expected ) && FD_ISSET ( mem->sock[i].s, &fds_send ) ) { |
| |
/* Echo data back */ | /* Echo data back */ |
n_sent = send ( mem->sock[i].s, mem->sock[i].buf + mem->sock[i].n_sent, min ( n_expected - mem->sock[i].n_sent, par->buflen ), 0 ); | n_sent = send ( mem->sock[i].s, mem->sock[i].buf + mem->sock[i].n_sent, min ( n_expected - mem->sock[i].n_sent, par->buflen ), 0 ); |