I am writing an application and I don't understand a point. I am trying to receive data from a specific client. In a TCP socket, accept returns to you an fd
number, so you can communicate over this fd
number with a specific client.
In recvfrom
, anything cannot specify that receive data from that client. It receives data from everyone who sent. I am trying to solve this, but I am not sure how to do this.
The second problem is that, after opening a socket, I open other socket. I send second socket number to client, and client sends second data on this second socket. In server side, the server listens to the first socket (not the second socket). But although client sends data from the second socket and the server listens to the first socket, server takes data. I print two socket as integer and see that two are different. How can the server read data that is sent on second socket, on the first socket?
Yeah, my question is a bit complicated. Basically I say:
recvfrom(sock, &client, sizeof(Client), MSG_WAITALL, (struct sockaddr *)&clientAddr2, &size);
How can tell a specific client (say client 2) to listen in the line above? (in TCP sockets, it is done by fd
number, but how it is in UDP socket?).