I want this. Suppose on client side I have
for (int i = 1 ; i < 4 ; i++)
sendToServer(i);
on server side I have
in = getFromClient();
sendToAllClients(clint.name + in);
that means I if I have two clients (client1 and client2) which send this in same time I will have something like this
client1:
client11
client12
client21
client13
client22
client23
client2:
client11
client12
client21
client13
client22
client23
actually I want to read and write in same time. I need a example code for this or something similar. I want to implement chat through http tunneling. I have implemented that using
InetAddress addr = InetAddress.getByName([some address]);
sock = new Socket(addr, TCP_PORT);
in = new BufferedReader(
new InputStreamReader(
sock.getInputStream()));
out = new PrintWriter(
new BufferedWriter(
new OutputStreamWriter(
sock.getOutputStream())), true);
Thanks.
> Ok. Can you give me simple code which is connecting
> through http tunneling.
Nothing you have posted so far suggests that http tunneling has anything at all to do with anything that you are doing.
Why do you think that it matters?
Are you getting an exception that tells you it matters? If so what is it?
> He has right.
You understand that the communication works a follows?
1. Client send request to proxy (server). To do this the client connects to the proxy.
2. Proxy send request to the final destination. To do this the proxy connects to the final destination.
3. The final destination returns a response to the proxy.
4. The proxy returns (repackages) the response to the client.
Yes, I understand (actually, I think I understand :))
Just, I don't know, can I have one connection client -> server, and one connection server -> clinet at once!?
It's very good if you have some short code to give me real example.Or I can post here simple chat code and you can tell me what I should change to work through http tunneling.
Thanks.
Message was edited by:
boba5555
> Yes, I understand (actually, I think I understand
> :))
> Just, I don't know, can I have one connection client
> -> server, and one connection server -> clinet at
> once!?
>
Yes, you use threads. Each client connection is in its own threead.
The tutorial covers this and every book on java networking that I have seen.