if I want ONLY to receive data from a client, and not send data out, is it necessary have a connect() in the code of my server?
Or is it sufficient to have the following?
socket();
bind();
listen();
accept();
This describes the basic principle of server-client interaction. As you can see, the client must connect
to the server before any interaction.
Once you've built a socket descriptor with the socket() call, you can connect that socket to a remote server using the well-named connect() system call.
Also the sequence you mentioned is in the server
. If you want to only receive data from server, just do the read
in client and write
in server. But connect
is neccessary.