Presentation is loading. Please wait.

Presentation is loading. Please wait.

Sockets in C. 2 References Manual Pages %torch man –s 3socket … Socket, bind, listen, etc. %torch man –s 3c select Resources section of website.

Similar presentations


Presentation on theme: "Sockets in C. 2 References Manual Pages %torch man –s 3socket … Socket, bind, listen, etc. %torch man –s 3c select Resources section of website."— Presentation transcript:

1 Sockets in C

2 2 References Manual Pages %torch man –s 3socket … Socket, bind, listen, etc. %torch man –s 3c select Resources section of website

3 3 Java… Java is a high-level language (HLL) It does a lot of work for the programmer It hides much of the complexity of n/w programs This can be very good, but not when you need to understand what is happening in your programs

4 4 … and C C is not exactly a HLL It has many features that are close to the operating system and processor Yet if it is used carefully, with standard libraries, etc., It can be portable It can also be an unholy mess

5 5 Steps to Make a Server Socket 1. Make a socket Like opening a file 2. Bind a socket Attach it to a specific port 3. Tell it to accept connections (for stream sockets only) 4. Receive data into a buffer

6 6 Socket Descriptor Sets Sockets in C are in groups Called fd_set s (file descriptor sets) The O/S will send a signal when one of the sockets in your fd_set has data to read We use these in the accept loop

7 7 The Accept Loop in C While (1) { clear all flags set flags to say which sockets to monitor wait for accept() to return read data from socket or sockets  receive  send  Close }


Download ppt "Sockets in C. 2 References Manual Pages %torch man –s 3socket … Socket, bind, listen, etc. %torch man –s 3c select Resources section of website."

Similar presentations


Ads by Google