1. A Few General Notes:
    You must write your code in C (not C++) and use either the cc or gcc compilers. When compiling on a Linux machine simply write:
    gcc -o myprgrm myprogram.c
    This will create an executable file named myprgrm.
    If you compile on a Solaris machine you must add two additional arguments like this:
    gcc -lsocket -lnsl -o myprgrm myprogram.c
    You should run the client and server on two different machines. If you are copying a file have the client in a seperate folder from the server.
    You can use the Linux servers shana9, shana10, or ise. You can also use the Solaris machines srs1, srs2, or ketubot (solapp).

    Some of the definitions and structures are different between the two types of systems, so what compiles on one might not compile on the other. But you can easily adapt the examples.

    Because of firewall configurations at JCT, TCP/IP communication on non-standard ports is blocked for machines on different subnets. This means your client and server must be on the same subnet. srs1 and srs2 are on subnet 103, shana9 and shana10 are on subnet 3 and ise and ketubot are on subnet 37. Subnet 103 and 3 should be considered the same subnet.
    Some of the documentation and examples are in pseudo-code instead of real C code, because the real C code is very verbose, and I thought it would be easier to understand the socket functions in pseudo-code.

  2. Administrative Information:
    Nachum Danzig Email:
    Office: Weiler 232 telephone: 02-675-1218

  3. Assignments

  4. TFTP Project

  5. Theory Questions

  • Socket Functions
    1. Summary of socket functions in pseudo-code.
      I suggest that you start here. These notes were designed for use with a lecture, but they should be helpful even by themselves. Please e-mail me comments about them (see e-mail address below).
    2. Here are some pseudocode and C code examples:
      1. Common to both UDP and TCP
        1. Socket address conversion functions -- convert between text and the sockaddr_in structure.

          Here is a program to test it.

        2. null_str function -- used by some of the other routines. This simply treats a NULL pointer as a an empty string.
        3. Create socket function -- Socket code is complex because the socket interface was designed to handle a lot more than just TCP/IP. This is an example of a wrapper function that makes TCP/IP socket programming simpler.
        4. Structures, Holes, and Unions in C -- This is not specific to sockets, but you look at this information anyway. It is not long.
        5. How to use printf.
      2. UDP
        1. Simple server and client
        2. UDP daytime example (another simple example)
          • Pseudocode Description
          • client -- As of 30 Cheshvan 5760 (09/11/1999), this tries only the well-known port for the 'daytime' service. If you want, you can try to change it so that you can specify which port it should try.
          • server -- As of 30 Cheshvan 5760 (09/11/1999), I have not yet tested this, because the client is not flexible enough (see above). I could have used the simple client above, but I have not yet.
        3. Synchronization tester -- this server allows you test what happens when you send a message to a UDP server before it is ready to accept it. Use the simple client to test it.
        4. Timeouts -- how to implement timeouts. We show how for UDP, though you can then figure out how to use it for TCP.
      3. TCP -- Here is code that demonstrates TCP fragmenting of streams.

    3. Related Functions and include files.
      These are functions that do not work directly with sockets, but are often needed when programming sockets. There are links to C programs that use these functions.

      Some of these functions are also mentioned in the main socket function above. I have left them in here.

  • Other Links:

    1. Beej's Guide to Network Programming.

    2. Lecture Notes on TCP/IP and UDP/IP.
      This is a detailed summery of the theory part of Dr. Bloch's TCP/IP class.

    3. IBM's TCP/IP tutorial.
      This is an excellent tutorial on TCP/IP. While it does not deal with programming with sockets, I recommend this as material for learning or reviewing the principles of TCP/IP.

    4. Another TCP/IP Guide

    5. And another guide

    6. How to use UNIX for this lab. This includes editing, compiling, and running more than one process at once.

    7. TFTP (the Trivial File Transfer Protocol)

    8. Interprocess communication mechanisms other than sockets

    9. Get more info about TCP/IP and sockets

    10. Dr. Seuss's Guide to the Internet (humor)