Kiedyś pisałem sobie aplet na WWW, taki prosty, nie wiem już o co w nim chodzi
ale może coś Ci pomoże (server był w Delphi):
import java.io.*;
import java.net.*;
import java.awt.*;
import java.applet.*;
import java.awt.event.*;
public class MyApl extends Applet implements KeyListener {
TextArea tA;
TextField tF;
Socket sck;
public void init() {
tA = new TextArea();
tF = new TextField();
BorderLayout bL = new BorderLayout();
tA.setEditable(false);
tF.setForeground(Color.yellow);
tA.setBackground(Color.white);
tF.setBackground(Color.white);
tF.addKeyListener(this);
this.setLayout(bL);
this.add(tA, bL.CENTER);
this.add(tF, bL.SOUTH);
try {
sck = new Socket(getDocumentBase().getHost(), 56491);
Thread rcvThrd = new MyThread();
rcvThrd.start();
}
catch (IOException ioE) {
tA.append(ioE.getMessage() + "\n");
}
}
class MyThread extends Thread {
public void run() {
try {
int buffSize;
byte buff[] = new byte[1024];
while (true) {
buffSize = sck.getInputStream().read(buff);
if(buffSize > 0) {
String str = new String(buff);
tA.append(str.substring(0, buffSize) + "\n");
}
}
}
catch (IOException ioE) {
tA.append(ioE.getMessage() + "\n");
}
}
}
public void destroy() {
try {
sck.close();
}
catch (IOException ioE) {
tA.append(ioE.getMessage() + "\n");
}
}
public void keyPressed(KeyEvent e) {
if(e.getKeyCode() == 10) {
try {
sck.getOutputStream().write(tF.getText().getBytes());
}
catch (IOException ioE) {
tA.append(ioE.getMessage() + "\n");
}
tF.setText("");
}
}
public void keyReleased(KeyEvent e) {
}
public void keyTyped(KeyEvent e) {
}
}