Java Serversocket.accept() does not return socket in the sequence of connect from client? -
we create 2 connections between java server , c++ client. java serversocket object phone call accept() twice , each returns 1 socket; c++ client phone call connect() twice. assume port of 1st socket returned accept() should same port of first client socket calling connect(), , same 2nd pair sockets.
but examine port number on each socket, have seen abnormal case occasionally, in 1st socket accept() connect 2nd client socket calling connect(), , 2nd socket accept() connect 1st client socket.
both server , client single threaded here establishing connection. how can sequence reversed ?
the order of initial synchronization packets 2 connections may switched on network. illustration if "first" connection's initial syn packet dropped , packet isn't resent until after initial syn packet of "second" connection. in addition, if server , client singly threaded, scheme code handles tcp stack may multithreaded.
java sockets port sequence connect
No comments:
Post a Comment