This could just be me being stupid, but I'm opening up two different applications on my computer that connect to the same port of a server running on the computer. Now, it's fine with one application connected, but once the other one is launched it starts throwing a bunch of exceptions about java.io.StreamCorruptedException: invalid type code: AC.. Is this because I'm trying to have the 1 server + 2 clients running on the same machine?
Edit: Code:
Socket socket = new Socket(InetAddress.getByName("127.0.0.1"),12352);
SocketThread sthread = new SocketThread(socket);
...
sthread.start();
Inside the socket thread:
this.ois = new ObjectInputStream(socket.getInputStream()); <-- ois is a variable for the ObjectInputStream
...
Packet packet = (Packet) ois.readObject(); <-- Error appears on this line.
Edit #2: Second - server code:
while(true)
{
Socket player = server.accept();
System.out.println(player.getRemoteSocketAddress().toString() + " connected.");
startSocket(player);
}
public static void startSocket(Socket player) throws IOException
{
new SocketThread(player).start();
}
Now, there is no errors on the server.