Sean Baker's book is the one that I have assigned for
this course.
The format of the exams (Midterm and Final) and all
other assignments will be a take-home program.
There will be approximately 2 programming assignments.
The assignments will be posted on my web site. The due dates are normally
two weeks from the time the programs are posted. You should check the course
web site on a reguler basis for any new announcements. I WILL NOT SEND
YOU ANY NOTIFICATIONS AFTER POSTING AN ASSIGNMENT.
You MUST use my on-line upload utility to submit your
assignment.
The close() call is used to close the socket. However,
if you kill the process before it has the chance to execute the close command,
the system will continue to consider the socket in use for some time.
There is a system call that returns the hostname:
int gethostname(char *name, int namelen);
The following is an excerpt from the manual page of this command:
DESCRIPTION The gethostname() function returns the standard host name for the current processor, as previously set by sethost- name(). The namelen argument specifies the size of the array pointed to by name. The returned name is null- terminated unless insufficient space is provided.
RETURN VALUES Upon successful completion, gethostname() and sethostname() return 0. Otherwise, they return -1 and set errno to indi- cate the error.
Here is an example of a simple program I wrote which when I run tells the host name of my machine:
#include <stdio.h>
main() { char name[20]; int size=20; gethostname(name,
size); printf("%s\n", name); }
1) let's assign each branch a number (e.g. 1, 2, etc.)
2) The directory server has a list of each account and
the branch number to which the account belongs. For example,
|
|
|
|
|
|
|
|
|
|
|
|
4) When the ATM contacts the directory server to inquire about a certain
account, the response it receives will inform it about the branch number.
5) The ATM uses the branch number information to contact the branch that maintains the account. The ATM knows the location of each branch.
Since we don't want to hardcode the host names of where
the servers will be running within any of the programs, you should use
command line arguments to pass this information to the programs. For example,
when you run the ATM you can pass it arguments that informs it where the
directory and the branch servers are running.
1) Set your LD_LIBRARY_PATH to /usr/lib or
2) Use "cc myfile.c /usr/lib/libnsl.so
/usr/lib/libresolv.so /usr/lib/libsocket.so"
3) OR Use "cc myfile.c -lnsl -lsocket"
4) On some systems you may have to use "cc myfile.c -lnsl
-lsocket"