CS360 Lab #8 -- Jtalk

  • Jim Plank
  • CS360
  • Url: http://www.cs.utk.edu/~plank/plank/classes/cs360/360/labs/lab8/lab.html

    This assigment is for you to write jtalk1 and jtalk2. These are programs that let two or more people on different accounts on different machines talk via Unix sockets. It is different from the standard Unix talk program in that it doesn't give the pseudo two-screen effect, it needs command line arguments for host, port and server/client, and (in jtalk2), it allows for more than two people to talk.


    Part 1: Write jtalk1.c

    This is a program that lets two people talk with each other. It is called as follows:
    jtalk1 host port c|s
    
    The last argument is "c" or "s" as in minitalk.c, to specify whether the caller is a client or server. The server serves a socket and waits for a client. The client requests a connection to the server. When the two connect, jtalk1 should allow them to talk. Whenever one types a line into a jtalk1 process, the line should be prepended with "username: " and printed to both the caller and the other screen. Thus, suppose I call:
    UNIX> jtalk1 plank 6543 s
    
    on my machine, and Slade (dfoster) calls:
    UNIX> jtalk1 plank 6543 c
    
    Then if I type "yo Slade -- how was the lecture" into my jtalk1 process, then my xterm will look like:
    UNIX> jtalk1 plank 6543 s
    Connected with client dfoster.  Type at will:
    
    yo Slade -- how was the lecture
    
    plank: yo Slade -- how was the lecture
    
    dfoster: fine
    
    and Slade's will look like:
    UNIX> jtalk1 plank 6543 c
    Connected with server plank.  Type at will:
     
    plank: yo Slade -- how was the lecture
    
    fine
    
    dfoster: fine
    
    Note that jtalk1 should print out some stuff as above when the two process's connect.

    Jtalk1 should be written such that the client and the server are each one process. Thus, you will have to use select() as described in class. You cannot use multiple processes as in minitalk.c.

    If you'd like to make jtalk1 a little more user friendly, make it so that line-continuation can be effected by ending a line with a backslash. Thus, if I type:

    Yo Slade --\
    How was lecture?
    
    Then Slade (and I) will see printed out:
    plank: Yo Slade --
        How was lecture?
    
    and not:
    plank: Yo Slade --\
    plank: How was lecture?
    
    This is optional, however.

    Part 2: Write jtalk2.c

    This is a program that lets n people talk with each other, where n is defined by the server. It is called in one of two ways:
    jtalk2 host port n
    
    or
    jtalk2 host port
    
    The former is the way the server calls jtalk2, and the latter is the way the clients call jtalk2. With jtalk2 the server is called, and waits for n-1 clients to attach to it. Then whenever anyone types into their jtalk2 process, their username is prepended to the string, which is printed out in all n jtalk2 processes. Thus, the following is an example of me serving a jtalk2 session on my machine with Slade and Michael (puening): As before, each jtalk2 server/client should consist of just one process. It should be obvious that all lines of text should go to the server who will broadcast them to all the clients. All processes will need to use select(). Socketfun.o and Socketfun.h are in the cs360/objs and cs360/include directories respectively.