# \[Java\] 'Network' library related - server issue

**URL:** <https://discourse.processing.org/t/java-network-library-related-server-issue/44579>\
**Category:** Libraries\
**Created:** [June 11, 2024, 8:00am UTC](https://discourse.processing.org/t/java-network-library-related-server-issue/44579 "2024-06-11T08:00:16Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![GWAK](https://avatars.discourse-cdn.com/v4/letter/g/13edae/32.png) [@GWAK](https://discourse.processing.org/u/GWAK)\
**Post date:** [June 11, 2024, 8:00am UTC](https://discourse.processing.org/t/java-network-library-related-server-issue/44579/1 "2024-06-11T08:00:16Z")

</div>

[JAVA] ‘Network’ library related - server issue

hello.

Reference link: [available() / Libraries / Processing.org](https://processing.org/reference/libraries/net/Server_available_.html)

 ![fig2](https://canada1.discourse-cdn.com/flex036/uploads/processingfoundation1/original/3X/1/1/11afb3d60acb03ec5e098390811e0e5828bfb37c.jpeg)

```auto
  Client thisClient = myServer.available();
  if (thisClient !=null) {
  // 1) T1 : Initial connection time
    String whatClientSaid = thisClient.readString();
    if (whatClientSaid != null) {

 // 2) operations, functions, calculations

    }
  // 3) T2 : Finish time

  }

```

Please refer to the picture.  
‘TCP SERVER’ operates in ‘DRAW(LOOP)’.  
However, when times overlap as shown in the picture, an error occurs. Is there any way to solve this problem?  
(Summary: If signals overlap during work, an error occurs)

---

<div class="post-metadata">

**Author:** ![GWAK](https://avatars.discourse-cdn.com/v4/letter/g/13edae/32.png) [@GWAK](https://discourse.processing.org/u/GWAK)\
**Post date:** [June 12, 2024, 11:52am UTC](https://discourse.processing.org/t/java-network-library-related-server-issue/44579/2 "2024-06-12T11:52:29Z")

</div>

Client thisClient = myServer.available();

Q1. myServer.available() / Can’t this be made in thread form?

---

<div class="post-metadata">

**Author:** ![glv](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/glv/32/18785_2.png) [@glv](https://discourse.processing.org/u/glv)\
**Post date:** [June 12, 2024, 6:49pm UTC](https://discourse.processing.org/t/java-network-library-related-server-issue/44579/3 "2024-06-12T18:49:09Z")

</div>

Hello @GWAK ,

These are available to you and run independently of the draw() loop:

- [serverEvent() / Libraries / Processing.org](https://processing.org/reference/libraries/net/serverEvent_.html)
- [clientEvent() / Libraries / Processing.org](https://processing.org/reference/libraries/net/clientEvent_.html)

I modified the _SharedCanvasClient_ and _SharedCanvasServer_ to use only events (draw was empty for each of them) and some handshaking to request new data only after it was received. It even worked with noLoop()!

![image](https://canada1.discourse-cdn.com/flex036/uploads/processingfoundation1/original/3X/4/0/40c9cb805849b09876465ebb8b368abec1693cc4.png)

Reference:

_[thread() / Reference / Processing.org](https://processing.org/reference/thread_.html)_

`:)`

---

<div class="post-metadata">

**Author:** ![GWAK](https://avatars.discourse-cdn.com/v4/letter/g/13edae/32.png) [@GWAK](https://discourse.processing.org/u/GWAK)\
**Post date:** [June 12, 2024, 8:08pm UTC](https://discourse.processing.org/t/java-network-library-related-server-issue/44579/4 "2024-06-12T20:08:58Z")

</div>

@glv

Yes, thank you for your reply.  
It might be usable. thank you.
