Need help in applets-servlet communication

Hello friends!

I'm programming the multi-player game. The clients are applets and the server side I build with servlets. I'm use this method of connect and transfer the data(this is applet code) :

URL servletURL = new URL(URL_to_servlet);

URLConnection servletConnection = servletURL.openConnection();

Write the message to the servlet:

PrintStream out = new PrintStream(servletConnection.getOutputStream());

out.println(some_data);

out.close();

Read from the servlet:

InputStream in = servletConnection.getInputStream();

StringBuffer response = new StringBuffer();

int chr;

while ((chr=in.read())!=-1) {

response.append((char) chr);

}

in.close();

On servlet in doPost method I read the data from applet:

StringBuffer msgBuf = new StringBuffer();

BufferedReader fromApplet = req.getReader();

String line;

while ((line=fromApplet.readLine())!=null) {

if (msgBuf.length()>0) msgBuf.append('\n');

msgBuf.append(line);

}

fromApplet.close();

and write to applet:

resp.setContentType("text/plain");

PrintWriter toApplet = resp.getWriter();

toApplet.println(some_data);

toApplet.close();

The question is: How can I do that many clients transfer the data between them through the servlet at the same time?

On the client I did one method that write data to servlet and in Thread I did the method that all time try to read the data from the server. But I don't know how can I do in the servlet smthng for good transfer data.

Help me please...I'll be very thankful.

[1689 byte] By [Vovchyka] at [2007-10-2 2:20:17]
# 1
You need to read a bit about sessions and maps. -Good luck.
MortenHjerlHansena at 2007-7-15 20:12:39 > top of Java-index,Other Topics,Java Game Development...