sent data to paticular socket from server when have multiple client
-
07-03-2021 - |
質問
I have 4 different application running.so every application can send data to server. now i want to send data to paticular socket (server and client are done through socket programming) from server side.
解決
When you create a socket, first you establish a connection between a server and a client (using connect
system call on the client side, and bind
, listen
, and accept
system calls on the server side). You can have many such connections, from a server to different clients. The server can send data on any of these established connections.
The Sockets Tutorial can assist you in this case.
If you want multiple reads/writes by the server to happen at the same time, you have to use non-blocking sockets or multiple threads.
他のヒント
(Assuming you're using TCP/IP, or UDP).
A socket endpoint is the IP address and port number combined. So, on your host you would have your various servers listen on different port numbers. For example a web server may listen on port 80, ssh on a different port etc.