# Use other sockets with Processing network client

**URL:** <https://discourse.processing.org/t/use-other-sockets-with-processing-network-client/2203>\
**Category:** Coding Questions\
**Created:** [July 30, 2018, 12:26pm UTC](https://discourse.processing.org/t/use-other-sockets-with-processing-network-client/2203 "2018-07-30T12:26:15Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![0x5e](https://avatars.discourse-cdn.com/v4/letter/0/df788c/32.png) [@0x5e](https://discourse.processing.org/u/0x5e)\
**Post date:** [July 30, 2018, 12:26pm UTC](https://discourse.processing.org/t/use-other-sockets-with-processing-network-client/2203/1 "2018-07-30T12:26:15Z")

</div>

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 `processing.net.*`

Here’s an example of my issue:  
(Python)

```auto
from socket import socket
a = socket()
a.bind(('0.0.0.0', 9050))
a.listen(1)
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')

```

(Processing)

```java
import processing.net.*;

Client client;

void setup() {
    client = new Client(this, "127.0.0.1", 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
    println(in);
}

```

(Error, from Processing)

```auto
Receiving:h
error, disabling clientEvent() for 127.0.0.1
java.lang.reflect.InvocationTargetException
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.lang.reflect.Method.invoke(Method.java:498)
	at processing.net.Client.run(Unknown Source)
	at java.lang.Thread.run(Thread.java:748)
Caused by: java.lang.ArrayIndexOutOfBoundsException: 1
	at server.clientEvent(server.java:49)
	... 6 more

```

---

<div class="post-metadata">

**Author:** ![0x5e](https://avatars.discourse-cdn.com/v4/letter/0/df788c/32.png) [@0x5e](https://discourse.processing.org/u/0x5e)\
**Post date:** [July 30, 2018, 12:48pm UTC](https://discourse.processing.org/t/use-other-sockets-with-processing-network-client/2203/2 "2018-07-30T12:48:42Z")

</div>

Here’s the full story.

I’m stupid.

---

<div class="post-metadata">

**Author:** ![tony](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/tony/32/949_2.png) [@tony](https://discourse.processing.org/u/tony)\
**Post date:** [July 30, 2018, 2:09pm UTC](https://discourse.processing.org/t/use-other-sockets-with-processing-network-client/2203/3 "2018-07-30T14:09:24Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![0x5e](https://avatars.discourse-cdn.com/v4/letter/0/df788c/32.png) [@0x5e](https://discourse.processing.org/u/0x5e)\
**Post date:** [August 1, 2018, 10:23am UTC](https://discourse.processing.org/t/use-other-sockets-with-processing-network-client/2203/4 "2018-08-01T10:23:34Z")

</div>

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

```auto
error, disabling clientEvent() for 127.0.0.1

```

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.

```auto
Caused by: java.lang.ArrayIndexOutOfBoundsException: 1
	at server.clientEvent(server.java:49)

```

I fixed that issue.
