Re: Socket programming: Command and Data socket



rsergeant <rsergeant@xxxxxxxxx> writes:
I am learning about socket programming from the books from Richard
Stevens. I just started, but browsing thru the books I didn't find an
example of how one could implement a program that uses two sockets for
communication (like for example the FTP command, which uses a data and
a command socket).

I am trying to write such a program myself, but I can't really get
around the design of the program. My questions is relatively simple (I
think). How would I go about setting up communication with two
sockets? I just need ideas on how to do this. I've been trying to get
this working for a long time, but I guess my design is wrong.

There are basically two options: Use a thread for each socket. Use an
I/O multiplexing routine to distribute I/O-tasks some number of threads
less than the number of sockets. The basic system calls for this would
be 'poll' and 'select'. 'poll' is easier to use and more efficient for
small sets of descriptors, 'select' is not the AT&T designed interface
(important quality :->), was a clever hack on VAXen when the running
kernel supported at most 32 open descriptors per process and is
portable to Windows.

I can get it to work in a none concurrent program, but I want to allow
multiple clients connecting from the same or different machines. The
program has to be some kind of FTP alike, but a lot simpler. The
clients asks for a list of files and the server returns this. The
clients asks for a specific file and the server returns this files in
blocks of 1024 bytes (The file is send over another port than the file
names).

The easiest way to do this is to fork a new process for each newly
accepted connection. This is not the most efficient way to implement
such a server, but completely appropriate for servers servicing
relatively few clients.
.



Relevant Pages

  • sockets, closing and TIME_WAIT
    ... During heavy load the server can't follow anymore because the sockets ... my server should be able to handle 10 clients connecting ... This gets a free position in the array of connections, ...
    (comp.unix.programmer)
  • Re: blocking non blocking
    ... not connected to incoming data on the same thread, async sockets have to be ... somehow a server with 50K threads, ... or overlapped I/O servicing 50K clients. ... read and learnt about blocking and non blocking, ...
    (microsoft.public.win32.programmer.networks)
  • Re: Ideas required for usage of sockets API for efficient network programs
    ... I am evaluating various methods of using sockets API for a network ... The server reads data from clients and writes data to clients. ...
    (comp.os.linux.development.apps)
  • Re: Moving files from clients to the server
    ... I'm not very familiar with sockets but I'll look into that, ... >> files should be passed to the server. ... the fastest way to create them is on the clients' machines. ... >> Another solution is to steam the files over the network. ...
    (microsoft.public.vc.atl)
  • Re: Autodiscover design for the organization
    ... There is an SCP for each CAS role server, and these are replicated across your multiple domain controllers. ... Then if you want to design additional redundancy in your Autodiscover and other CAS services, you can build load balancing among yoru CAS role servers. ... 2k7 clients to retrieve the Autodiscover server, ... you will need fully redundant servers with redundant power ...
    (microsoft.public.exchange.design)