List of Listings

 < Day Day Up > 

 



Chapter 2: Introduction to Sockets Programming

Listing 2.1 Daytime protocol server (server.c).
Listing 2.2 Daytime protocol client (client.c).

Chapter 3: Standard BSD API Functions

Listing 3.1 Example usage of the socket function.
Listing 3.2 Format of the sockaddr_in address structure.
Listing 3.3 Example of the bind function for a server socket.
Listing 3.4 Sample code example for the accept function.
Listing 3.5 Sample code for the connect function in a stream socket setting.
Listing 3.6 Example of the recv function in a stream setting.
Listing 3.7 Example of the recvfrom function in a datagram setting.
Listing 3.8 Example of the send function with a stream socket.
Listing 3.9 Example of the sendto function with a datagram socket.
Listing 3.10 Examples of the socket address functions.

Chapter 4: Advanced Sockets Functions

Listing 4.1 Simple example of the select function for a read event.
Listing 4.2 Simple select example for read events with a timeout.
Listing 4.3 Using getsockname to gather the local address information for a socket.
Listing 4.4 Using getpeername to gather the peer address information for a socket.
Listing 4.5 Getting and then setting the send buffer size for a socket.
Listing 4.6 Sample usage of the gethostname function.
Listing 4.7 Sample usage of the sethostname function.
Listing 4.8 Sample usage of the gethostbyaddr function.
Listing 4.9 Sample usage of the gethostbyname function.
Listing 4.10 Typical usage of the gethostbyname function with inet_addr (resolve.c).
Listing 4.11 Sample usage of the resolve_name function.
Listing 4.12 Simple example of getservbyname.
Listing 4.13 Complete example of getservbyname.
Listing 4.14 Example of the getservbyport function.
Listing 4.15 Sample of a Unix /etc/services file.

Chapter 5: Socket Options

Listing 5.1 SO_BROADCAST and sending a broadcast datagram.
Listing 5.2 Enabling TCP layer debugging with SO_DEBUG.
Listing 5.3 Manipulating the SO_DONTROUTE socket option.
Listing 5.4 Retrieving the SO_ERROR value for a socket.
Listing 5.5 Example of the SO_LINGER socket option.
Listing 5.6 Disabling the TCP keep-alive probes.
Listing 5.7 Modifying the send and receive socket buffer sizes.
Listing 5.8 Setting SO_RCVLOWAT to await 48 bytes before read operation return.
Listing 5.9 Setting SO_SNDLOWAT to await 48 bytes before write operation.
Listing 5.10 Retrieving the SO_SNDTIMEO timeout values.
Listing 5.11 Sample server code for the “address in use” error.
Listing 5.12 Enabling local address reuse with SO_REUSEADDR.
Listing 5.13 Setting keep-alive probes to 10-second intervals.
Listing 5.14 Defining a three-second TCP_MAXRT.
Listing 5.15 Disabling the Nagle algorithm.
Listing 5.16 Defining a static MSS for a given socket.
Listing 5.17 Providing an IP header for an IP datagram (ipdgram.c).
Listing 5.18 Defining an IP Type of Service for a given connection.
Listing 5.19 Defining an IP Time To Live of one for a given connection.
Listing 5.20 Subscribing to a multicast group for a given connection.
Listing 5.21 Leaving a multicast group for a given connection.
Listing 5.22 Setting the outgoing multicast interface for a given connection.
Listing 5.23 Setting the IP_MULTICAST_TTL.
Listing 5.24 Setting the IP_MULTICAST_LOOP.

Chapter 6: Advanced Sockets Programming Topics

Listing 6.1 Receiving out-of-band data using sockatmark.
Listing 6.2 Making a socket nonblocking on a Unix system.
Listing 6.3 Detecting peer closure using input calls.
Listing 6.4 Detecting peer closure using output calls.
Listing 6.5 Resolving an unknown type of address.
Listing 6.6 Server accepting connections from all interfaces.
Listing 6.7 Server accepting connections from a specific interface.
Listing 6.8 Server differentiating based upon connect interface (bindtest.c).
Listing 6.9 Simple port scanner illustrating timing out the connect function (portscan.c).
Listing 6.10 Source illustrating framing (lack of) in TCP stream sockets (tcpframe.c).
Listing 6.11 Source illustrating framing in UDP datagram sockets (udpframe.c).
Listing 6.12 Datagram socket in an unconnected state.
Listing 6.13 Datagram socket in a connected state.
Listing 6.14 Timing out a read operation.
Listing 6.15 Identifying the peer using getpeername.
Listing 6.16 Finding the unique protocol number (proto.c).
Listing 6.17 Using getprotobyname for the socket function.
Listing 6.18 Enumerating the services table (servenum.c).

Chapter 7: Optimizing Sockets Applications

Listing 7.1 Configuring the socket buffer sizes.
Listing 7.2 Multiple writes for a series of data.
Listing 7.3 Single write for higher performance.

Chapter 10: Network Programming in Java

Listing 10.1 Sample URL example (host.java).

Chapter 11: Network Programming in Python

Listing 11.1 Python TCP server illustrating the select method.
Listing 11.2 Sample smtplib client example.
Listing 11.3 Sample httplib client example.
Listing 11.4 Sample SocketServer example.

Chapter 12: Network Programming in Perl

Listing 12.1 Perl TCP server illustrating the select method.
Listing 12.2 Sample Net::SMTP client example (smtpc.pl).
Listing 12.3 Sample LWP::Simple client example (httpc.pl).

Chapter 13: Network Programming in Ruby

Listing 13.1 Ruby TCP server illustrating the select method.
Listing 13.2 Sample Net::SMTP client example.
Listing 13.3 Sample Net::HTTP client example (httpc.rb).

Chapter 16: Network Code Patterns in C

Listing 16.1 C language Daytime stream server.
Listing 16.2 C language Daytime stream client.
Listing 16.3 C language Daytime datagram server.
Listing 16.4 C language Daytime datagram client.
Listing 16.5 C language Daytime multicast server.
Listing 16.6 C language Daytime multicast client.
Listing 16.7 C language Daytime broadcast server.
Listing 16.8 C language Daytime broadcast client.
Listing 16.9 Simple HTTP server function start.
Listing 16.10 Simple HTTP server function handle_connection.
Listing 16.11 Simple HTTP server function handle_get_method.
Listing 16.12 Simple HTTP server function emit_response_header.
Listing 16.13 Simple SMTP client sendMail function.
Listing 16.14 Simple SMTP client dialog function.

Chapter 17: Network Code Patterns in Java

Listing 17.1 Java Daytime stream server.
Listing 17.2 Java Daytime stream client.
Listing 17.3 Java Daytime datagram server.
Listing 17.4 Java Daytime datagram client.
Listing 17.5 Java Daytime multicast server.
Listing 17.6 Java Daytime multicast client.
Listing 17.7 Java Simple HTTP server source.
Listing 17.8 Java Simple SMTP client source.

Chapter 18: Network Code Patterns in Python

Listing 18.1  Python Daytime stream server.
Listing 18.2  Python Daytime stream client.
Listing 18.3 Python Daytime datagram server.
Listing 18.4 Python Daytime datagram client.
Listing 18.5 Python Daytime multicast server.
Listing 18.6 Python Daytime multicast client.
Listing 18.7 Python Daytime broadcast server.
Listing 18.8 Python Daytime broadcast client.
Listing 18.9 Python simple HTTP server source.
Listing 18.10 Instantiating a new Python HTTP server.
Listing 18.11 Python language SMTP client source.
Listing 18.12 Instantiating a new SMTP client.

Chapter 19: Network Code Patterns in Perl

Listing 19.1 Perl Daytime stream server.
Listing 19.2 Perl Daytime stream client.
Listing 19.3 Perl Daytime datagram server.
Listing 19.4 Perl Daytime datagram client.
Listing 19.5 Perl Daytime multicast server.
Listing 19.6 Perl Daytime multicast client.
Listing 19.7 Perl Daytime broadcast server.
Listing 19.8 Perl Daytime broadcast client.
Listing 19.9 Perl simple HTTP server source.
Listing 19.10 Perl language SMTP client source.

Chapter 20: Network Code Patterns in Ruby

Listing 20.1 Ruby Daytime stream server.
Listing 20.2 Ruby Daytime stream client.
Listing 20.3 Simplified Ruby Daytime stream client.
Listing 20.4 Ruby Daytime datagram server.
Listing 20.5 Ruby Daytime datagram client.
Listing 20.6 Ruby Daytime multicast server.
Listing 20.7 Ruby Daytime multicast client.
Listing 20.8 Ruby Daytime broadcast server.
Listing 20.9 Ruby Daytime broadcast client.
Listing 20.10 Ruby simple HTTP server source.
Listing 20.11 Instantiating a new HTTP server.
Listing 20.12 Ruby language SMTP client source.
Listing 20.13 Instantiating a new SMTP client.

Chapter 21: Network Code Patterns in Tcl

Listing 21.1 Tcl Daytime stream server.
Listing 21.2 Tcl Daytime stream client.
Listing 21.3 Tcl Daytime stream client using Tcl-DP.
Listing 21.4 Tcl Daytime datagram client.
Listing 21.5 Tcl Daytime multicast server.
Listing 21.6 Tcl Daytime multicast client.
Listing 21.7 Tcl Daytime broadcast client.
Listing 21.8 Tcl simple HTTP server source.
Listing 21.9 Starting the Tcl simple HTTP server.
Listing 21.10 Simple Tcl SMTP client source.



 < Day Day Up > 

 



BSD Sockets Programming from a Multi-Language Perspective
Network Programming for Microsoft Windows , Second Edition (Microsoft Programming Series)
ISBN: 1584502681
EAN: 2147483647
Year: 2003
Pages: 225
Authors: Jim Ohlund

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net