# Interesting finds in pylib, but how to use?

**URL:** <https://forum.inductiveautomation.com/t/interesting-finds-in-pylib-but-how-to-use/104912>\
**Category:** Ignition\
**Created:** [April 9, 2025, 4:40pm UTC](https://forum.inductiveautomation.com/t/interesting-finds-in-pylib-but-how-to-use/104912 "2025-04-09T16:40:35Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![slacasse1](https://avatars.discourse-cdn.com/v4/letter/s/b9e5f3/32.png) [@slacasse1](https://forum.inductiveautomation.com/u/slacasse1)\
**Post date:** [April 9, 2025, 4:40pm UTC](https://forum.inductiveautomation.com/t/interesting-finds-in-pylib-but-how-to-use/104912/1 "2025-04-09T16:40:35Z")

</div>

Hello,

As I was exploring user-lib/pylib, I've seen SocketServer.py containing classes to build a simple server. So I was thinking, maybe it's possible to send network messages (or commands), but I'm not sure how this could work in an existing gateway setup.

So the ignition receive a simple text message from the network but how could we generate an event for the network message? Or would there be another way to hanlde this? I was thinking about a thread running in the background, but I'm not sure if it can be done?

Also, turning ignition into a network client for another process could be interesting, but how to implement a simple query response protocol in ignition?

I did not find documentation on these topics so far, Any help, or links to documentation would be appreciated.

Thank you

---

<div class="post-metadata">

**Author:** ![pturmel](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/pturmel/32/3295_2.png) [@pturmel](https://forum.inductiveautomation.com/u/pturmel)\
**Post date:** [April 9, 2025, 4:44pm UTC](https://forum.inductiveautomation.com/t/interesting-finds-in-pylib-but-how-to-use/104912/2 "2025-04-09T16:44:04Z")

</div>

Under no circumstances should you use jython stdlib sockets of any kind. Use `java.net` or `java.nio` classes in your scripts.

There is no documentation in Ignition for such things. You would use java examples converted to jython syntax. You would also need to protect yourself from memory leaks due to running old code after project edits, as you generally need long-lived threads to service socket traffic.

[https://forum.inductiveautomation.com/search?q=long-lived%20threads%20order%3Alatest](https://forum.inductiveautomation.com/search?q=long-lived%20threads%20order%3Alatest)

---

<div class="post-metadata">

**Author:** ![paul-griffith](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/paul-griffith/32/37249_2.png) [@paul-griffith](https://forum.inductiveautomation.com/u/paul-griffith)\
**Post date:** [April 9, 2025, 4:49pm UTC](https://forum.inductiveautomation.com/t/interesting-finds-in-pylib-but-how-to-use/104912/3 "2025-04-09T16:49:35Z")

</div>

The only supported tool along these lines is the Webdev module, but it's specific to HTTP and is "higher level" than e.g. a simple unauthenticated TCP server:

> **[Web Dev | Ignition User Manual](https://docs.inductiveautomation.com/docs/8.1/ignition-modules/web-dev)**
>
> The Web Dev module enables you to directly program against the web server inside the Ignition Gateway. Webpages can be built by hand using a combination of Python programming and static web resources such as images, CSS files, JavaScript files, and...

---

<div class="post-metadata">

**Author:** ![slacasse1](https://avatars.discourse-cdn.com/v4/letter/s/b9e5f3/32.png) [@slacasse1](https://forum.inductiveautomation.com/u/slacasse1)\
**Post date:** [April 9, 2025, 5:05pm UTC](https://forum.inductiveautomation.com/t/interesting-finds-in-pylib-but-how-to-use/104912/4 "2025-04-09T17:05:08Z")

</div>

Thank you for your answer, I will read the documentation about long lived thread in ignition.

I figured that it is possible to used java code in ignition, but from a logger(log4j) example found on internet. It works nicely, but I did not understand well how to mix java and cython code. Any documentation on the topic of using java librairies?

Thanks again for your help

---

<div class="post-metadata">

**Author:** ![pturmel](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/pturmel/32/3295_2.png) [@pturmel](https://forum.inductiveautomation.com/u/pturmel)\
**Post date:** [April 9, 2025, 5:12pm UTC](https://forum.inductiveautomation.com/t/interesting-finds-in-pylib-but-how-to-use/104912/5 "2025-04-09T17:12:34Z")

</div>

> [@slacasse1](#):
>
> Any documentation on the topic of using java librairies?

This is fairly recent:

> **[Jython: Python and Java Integration Made Easy](https://ioflood.com/blog/jython/)**
>
> Are you a Python enthusiast looking to harness its power in a Java environment? Or perhaps a Java developer intrigued by Python's simplicity and dynamism?
