0
Answer

Multiple Socket Instances On A Single Port?

alexanderdb007

alexanderdb007

20y
1.6k
1
Hi, I'm trying to create a program that acts as a server as well as a client. Upon starting up, a new socket is bound and listens to a port number (In a seperate thread). Also, another thread creates an instance of another socket to connect to any servers. However, the socket is bound to the same port number as the socket thats listening for incoming connections. Upon testing it with a server program, I noticed that the "connection" side didn't work correctly. Although it connected, it didn't send the data as it should. However when I removed the server binding code, the connection worked fine. I really need to be able to do it in this way, with both socket instanes (in different classes) listening for incoming and connecting to servers. However is it possible to do this on the same port number? Or is there something else that might be preventing this from working? I'm using TCP for this. Thanks!