This
seems like a multiplexing problem.
I
assume you will want to de-multiplex at some later
point.
(I can
not fathom an application that would want to irreversibly mix together a bunch
of
independent tcp streams, but perhaps my powers of
imagination are lacking).
The
approach would be along these lines:
1)
Accept all incoming connections
2)
Whenever you read() a chunk of bytes from one of them, wrap these bytes
into
your
own custom header, which should have at least an ID to signify the original
connection where you
received it, possibly a sequence number, and
the length of the chunk.
3)
Given the above, you simply write all such chunks preceded by the above header
to the output
tcp
stream.
4) The
recipient can read the above chunks into separate buffers, and decipher the
header.
Given
that, the messages can now be reassembled into the original
streams.
cheers,
/sG
Ok here goes some crazy idea.
What I want to do is accept multiple TCP
connections, but yet, PIPE all the DATA into one single TCP
connection?
TCP---------\
\
TCP-----------\
\
TCP-------------======== TCP
/
TCP----------/
Hmm, lets see how outlook does with
ANSI...
Theories?
Mike
|