A forum for questions and answers about network programming on Linux and all other Unix-like systems

You are not logged in.

#1 2013-06-04 02:07 PM

Registered: 2013-06-04
Posts: 1

Socket programming

If somebody can help me to write this code ?

a)he server receives exactly two arguments on the command line: the TCP port number to which it listens and
the name of a configuration file.

b)he configuration file is a text file that lists zero or more servers, one per line. Each line is composed of two
ASCII strings separated by a space. The first string can be either the IPv4 address of the server host in dotted
decimal notation or the name of the server host. The second string is the server TCP port number.

c)The server interacts with the clients as specified in below:
(iterative TCP server)Develop a TCP server (listening to the port specified as first parameter of the command line)
accepting file transfer requests from clients and sending the requested file.
Develop a client able to connect to a TCP server (to the address and port number specified as
first and second command-line parameters, respectively) to request files and store them locally.
File names that needs to be requested must be provided using the standard input, one for line.
Every requested file must be saved locally and the client must print to the standard output a
message about the performed file transfer, with file name and size.
To request a file the client sends to the server the three ASCII characters "GET" followed by the
file name and CRLF (without any space):
GETfilename CR LF
The server replies by sending:
followed by the number of bytes (32-bit integer in network format) and then by the bytes of the
requested file.
The client can request more files by sending many GET commands. When it intends to
terminate the communication it sends:
and then it closes the communication channel.
In case of error (e.g. illegal command, non-existing file) the server always replies with:
and then it closes the communication channel with the client.
Test your client with the server developed by another group and vice-versa.
While a connection is active try to activate a second client against the same server.
Try to activate on the same node a second instance of the server on the same port.
Try to connect the client to a non-reachable address.
Try to connect the client to an existing address but on a port in which the server is not listening
Try to de-activate the server (by pressing ^C in its window) while a client is connected.

4)When the server receives a request for a file, it looks for the file in its local current directory. If the file is not
found, the server tries to get the file from one of the servers listed in its configuration file (the server interacts
with the other servers using the same protocol, but playing the client role). The server tries to contact the
servers in the configuration file one by one, in the same order as they appear in the file, until one of them
returns the file or the list scanning terminates.



#2 2013-06-04 07:51 PM

From: Boston, MA
Registered: 2002-06-12
Posts: 3,839

Re: Socket programming

That looks very clearly like a class project of some sort...  We don't just write people's homework assignments for them...  (And, certainly not for free!)  You won't learn anything that way...

Now, if you want to try writing it yourself, and have questions or trouble with certain parts of it, feel free to ask specific questions here, and we'll try to help...


Board footer

Powered by FluxBB