Network Basics

From ODF::Wiki

Jump to: navigation, search

[edit] How do IP, port and socket relate?

A socket is an endpoint of communication. Each pair of IP and port specify one socket. For example, the socket 123.123.123.123:4567 refers to port 4567 on host 123.123.123.123.

[edit] Blocking and Non-Blocking message passing

...

How do I set a socket non-blocking?

#include <fcntl.h>
int flags = fcntl(fd, F_GETFL);
fcntl(fd, F_SETFL, flags & O_NONBLOCK);
Personal tools