Sockets, Shellcode, Porting & Coding: Reverse Engineering Exploits and Tool Coding for Security Professionals

Berkeley Software Distribution (BSD) sockets are programming interfaces designed for inter-process communication (IPC). This interface is most commonly used by programmers to implement network-based communication between one or more computers. The Internet Protocol version 4 (IPv4), User Datagram Protocol (UDP), Transmission Control Protocol (TCP), and other associated protocols, known collectively as TCP/IPv4, are the de facto standards used by BSD sockets for IPC between processes running on different network-connected computers.
The BSD sockets programming interface can be used to implement various IPC designs, including one-to-one, one-to-many, and many-to-many communications. These are known as client/server or unicast, broadcast, and multicast communications, respectively.
In this chapter we take an in-depth look at the BSD sockets programming facility, including standard UDP and TCP client/server programming, fine tuning sockets with socket options and touch upon the applications of multi-threading in network programming.
| Note | All of the example source code in this chapter was written and compiled on OpenBSD 3.2 / x86 using the GNU C compiler version 2.95.3 and the tcsh command shell version 6.12.00. |
The BSD sockets programming facility is a collection of programming language functions and data types, which is known as the BSD sockets application programming interface (API). This facility was first introduced with the BSD UNIX operating system in the early 1980s, but is now available on most UNIX-like operating systems and supported on the Microsoft Windows platform (Winsock).
The BSD sockets API is widely used in conjunction with the C programming language to...