From the course: Network Programming in C: Develop Reliable Client/Server Applications

Unlock the full course today

Join today to access over 24,700 courses taught by industry experts.

Bind and connect

Bind and connect

- [Instructor] When you program a server, TCP or UDP, you use the bind function. When you program a TCP client, you use connect. UDP clients don't use a connect function. Remember, UDP is a connectionless protocol. The bind and connect functions do different things, but they support similar arguments so I'm covering them together. On the server side, the bind function's purpose is to name a socket to bind it to an address. Like the socket function, which is typically used before the bind call, this function is prototyped in the sys/socket.h header file. The bind function has three arguments. The first is a socket file descriptor. The value returned from a successful call to the socket function. The second argument is an address stored in a sock address structure. This information is conveniently stored in the structure returned by the get address info function as its fourth argument, the ai_addr member. The third…

Contents