Cheers for your input I really appreceate it, but I actually do create a
thread for each newly connected client and within that cread create I/O
streams to it, but for some reason its allways giving me the same IP as
the host pc the server is on.
I should also mention that I have tested the I/O from a different pc
connecting to my server and it worked, even though it was giving the
server IP as the newly connected client!!
Thanks Niall
Matt wrote:
Your code is a bit messy, but the idea is fine. Your accept method will
block until the client connects. Here's what's missing. Your server
should
then take the client socket and perform whatever service is required.
For
a
trivial server you can just answer one request and then close the
connection, but for anything more you should consider sending the request
to
a separate thread. The reason for this is that ideally, at the same
time,
the server (via the remainder of the while loop) would go back to try to
pickup another client.
Clients are distinguished by more than just their respective IP addresses
(a
tcp virtual circuit is identified by the IP and port addresses of both
ends)
which allows the same IP address to have multiple client connections and
all
of them to have the same server end point. What's key here is that the
same
server socket accepts all the client connections, one at a time and you
have
to manage what those client connections do.
Cheers,
Matt Humphrey (e-mail address removed)
http://www.iviz.com/