Click to See Complete Forum and Search --> : One Socket for listening and sending/receiving, simultaneously?


Aidman
September 15th, 2003, 06:49 AM
Hi,

Is it possible to use the same Windows socket for listening (for new connections) and at the same time exchanging data (using the sendto() and recvfrom() functions)? Or must I have two separate sockets, and if so must the separate sockets also be bound to separate network ports? Just for the info, I am using WinSock 2 API functions.

High thanks in advance :)

dimm_coder
September 16th, 2003, 10:59 AM
Originally posted by Aidman
Hi,

Is it possible to use the same Windows socket for listening (for new connections) and at the same time exchanging data (using the sendto() and recvfrom() functions)? Or must I have two separate sockets, and if so must the separate sockets also be bound to separate network ports? Just for the info, I am using WinSock 2 API functions.

High thanks in advance :)

There some errors in your questions :)
U've said: listerning for new connections - this means U have connection-oriented service - TCP-connection;
but then U've said: sendto(), recvfrom() - but those functions are ussualy used for UDP-connection.

Nevertheless, only for TCP-connection U can have a socket in listerning state which can accept new connections. And NO, if some socket has been set in LISTEN state (by listen() ), it cannot be used to send or recive any data, at least because it have not even any peer for it (simple deffinition :D), and U cannot use sendto(), because this is not UDP, but TCP-socket.