Free Programming E-Books
Free download ebooks on computer and programming | |||
Free Ebook Computer ProgrammingFree Ebook Computer Programming : Guide to Network Programming.pdf Publisher : Unknown Pages :49 Format :pdf Size :0.5 MB Upload date :06-16-05 Table of contentComing soon Other HOT and Free ebooks!!Coming Soon Free Ebook Network Programming : Guide to Network Programming.pdf2. What is a socket?You hear talk of "sockets" all the time, and perhaps you are wondering just what they are exactly. Well, they're this: a way to speak to other programs using standard Unix file descriptors. What? Ok-you may have heard some Unix hacker state, "Jeez, everything in Unix is a file!" What that person may have been talking about is the fact that when Unix programs do any sort of I/O, they do it by reading or writing to a file descriptor. A file descriptor is simply an integer associated with an open file. But (and here's the catch), that file can be a network connection, a FIFO, a pipe, a terminal, a real on-the-disk file, or just about anything else. Everything in Unix is a file! So when you want to communicate with another program over the Internet you're gonna do it through a file descriptor, you'd better believe it. "Where do I get this file descriptor for network communication, Mr. Smarty-Pants?" is probably the last question on your mind right now, but I'm going to answer it anyway: You make a call to the socket() system routine. It returns the socket descriptor, and you communicate through it using the specialized send() and recv() (man send4, man recv5) socket calls..........more Download free ebook : Beej's--Guide_to_Network_Programming.pdf
Previous free ebook Previous part of free ebook Next Free ebook Next part of free ebook "But, hey!" you might be exclaiming right about now. "If it's a file descriptor, why in the name of Neptune can't I just use the normal read() and write() calls to communicate through the socket?" The short answer is, "You can!" The longer answer is, "You can, but send() and recv() offer much greater control over your data transmission." What next? How about this: there are all kinds of sockets. There are DARPA Internet addresses (Internet Sockets), path names on a local node (Unix Sockets), CCITT X.25 addresses (X.25 Sockets that you can safely ignore), and probably many others depending on which Unix flavor you run. This document deals only with the first: Internet Sockets. | |||