Server listening on 2 differents ports

  • Thread starter ssantamariagarcia
  • Start date
S

ssantamariagarcia

I am trying to program a server in C for UNIX to get a kind of "bridge"
between the clients of a port A and the clients of a port B.
For that, I create 2 processes: one that listen the requests of port A
clients and another for the Port B ones.

In each process, when a connetion service is required, after accepting
, the value of the socket generated is added to a set of sockets. This
set keeps on listening on each socket for new messages to be read.

the question is that both processes get the same socket values, I
mean, the first client asking on port A get the same socket number that
the first one on port B. So I can not refer to a client in a unique way
, because there will be 2 clients with the same socket number .

I am using fork(), and in each process created, I use a method in
charge of creating the set of sockets and waiting for some event. I
suspect that the use of fork() is not right in this situation.........


In other words: If there is anybody who could know how to program a
server which is going to receive messages on 2 diferents ports and it
has to carry them from one port to another ( both ways), please, please
help me.


Thanks a lot !


(Sorry about my english)
 
L

Lawrence Kirby

I am trying to program a server in C for UNIX to get a kind of "bridge"
between the clients of a port A and the clients of a port B.
For that, I create 2 processes: one that listen the requests of port A
clients and another for the Port B ones.

In each process, when a connetion service is required, after accepting
, the value of the socket generated is added to a set of sockets. This
set keeps on listening on each socket for new messages to be read.

Your question is about Unix and socket programming which are not covered
by the C language itself. A good newsgroup to ask your question is
comp.unix.programmer.

Lawrence
 
C

CBFalconer

I am trying to program a server in C for UNIX to get a kind of
"bridge" between the clients of a port A and the clients of a
port B. For that, I create 2 processes: one that listen the
requests of port A clients and another for the Port B ones.
.... snip ...

(Sorry about my english)

Your English is satisfactory, your choice of newsgroups is not.
The C language knows nothing about ports, processes, clients,
forks, etc. You want a newsgroup that deals with those things.
Something with one of posix, linux, unix in its name seems
suitable.

Before posting there stop and read several days, or a weeks, worth
of postings. This should give you a strong feeling for whether or
not your query is topical. Read any welcome or FAQs associated
with the group.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,768
Messages
2,569,574
Members
45,050
Latest member
AngelS122

Latest Threads

Top