Use other sockets with Processing network client

I have written a game server in Python (it’s more fit for the job, with async and all). Now I’m working to integrate its functionality with Processing. I’m using Client from*

Here’s an example of my issue:

from socket import socket
a = socket()
a.bind(('', 9050))
b, c = a.accept()  # accepts connection from processing client
print(b.recv(1024).decode()) # so far so good, prints out -> gday
b.send(b'hello there')



Client client;

void setup() {
    client = new Client(this, "", 9050); // Connects to python server
    client.write("hello");  // so far so good

void clientEvent(Client client) {
    String in = client.readString();  // problem! program quits with error

(Error, from Processing)

error, disabling clientEvent() for
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(
	at java.lang.reflect.Method.invoke(
	at Source)
Caused by: java.lang.ArrayIndexOutOfBoundsException: 1
	at server.clientEvent(
	... 6 more

Here’s the full story.

I’m stupid.

1 Like

I’m curious (And I bet people in the future will be as well)

It’s important to note that the error displayed is slightly misleading.
When it says

error, disabling clientEvent() for

It is merely displaying a symptom of the actual issue. In fact, the actual issue was entirely unrelated to networking. The lesson to be learned is to notice the trace a few lines down.

Caused by: java.lang.ArrayIndexOutOfBoundsException: 1
	at server.clientEvent(

I fixed that issue.