answersLogoWhite

0

In socket programming, there are two sides to every conversation: the listener (or server), and talker (the client).

The server first opens a desired port, receives a socket handle, and begins listening for connections. It polls the socket every so often to listen for attempted connections by clients. Once a connection has been established, communication begins.

A client merely indicates an IP address and port to connect to. Once the connection is made, communication begins.

Then there are blocking and non-blocking sockets, which applies to both servers and clients. Blocking socketsforce the program to wait until there's activity before continuing its operation. So a server process will pause while waiting for a connection, and a client process will pause while waiting for the server to send data.

Under most conditions, non-blocking sockets are preferred. This allows the program to give up timeslices to the operating system, as well as conduct any activities in the background like listening to multiple connections (for servers).

Writing a socket program is about the same between Windows and Unix/Linux based systems, but there are some differences in setting up non-blocking sockets as well as initializing and closing the socket interface.

More information on both Win32 and Linux socket programming can be found in the related links below.

User Avatar

Wiki User

12y ago

What else can I help you with?

Continue Learning about Engineering