No Title

next up previous
Next: About this document

Second homework exercise

The second exercise is also on sockets, but to do it in a non-blocking way. Continue reading Beej's Guide to Network Programming to the end, the part about blocking and the select function.

Write a simple client-server program. The server accepts MANY clients (in a non-blocking way, using select). The server will be used to broadcast between the clients.

More precisely, when you type a string in any client, it sends the string to the server, which forwards it to the all the other clients, who output the string on the screen.

If during the last 10 seconds the client has not received either a string from the input or the server, it outputs some message.

A few programming tips:

  1. In order to convert hosts name (say "libra") to an IP address you can simply invoke gethostbyname (see the man page).
  2. Let the client receive the port number and the host name as a parameter. (The server can also get it's port number as a parameter.)
  3. Try to test the program with one another. You should be able to hook to someone else server and broadcast using it.

The exercise is due next week.

Mansour Yishay
Wed Mar 13 10:31:00 GMT+0200 1996