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.
jtalk1 host port c|sThe 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 son my machine, and Slade (dfoster) calls:
UNIX> jtalk1 plank 6543 cThen 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: fineand 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: fineNote 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.
jtalk2 host port nor
jtalk2 host portThe 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):
UNIX> jtalk2 plank 6789 3 Client dfoster has joined Client puening has joined Go ahead and talk: Yo Slade and Michael -- how was lecture? plank: Yo Slade and Michael -- how was lecture? dfoster: Fine -- I enjoyed it puening: I fell asleep
UNIX> jtalk2 plank 6789 Server: plank Client puening has joined Go ahead and talk: plank: Yo Slade and Michael -- how was lecture? Fine -- I enjoyed it dfoster: Fine -- I enjoyed it puening: I fell asleep
UNIX> jtalk2 plank 6789 Server: plank Client dfoster has joined Go ahead and talk: plank: Yo Slade and Michael -- how was lecture? dfoster: Fine -- I enjoyed it I fell asleep puening: I fell asleep