# Send/receive message via TCP socket

**URL:** <https://forum.inductiveautomation.com/t/send-receive-message-via-tcp-socket/96240>\
**Category:** Ignition\
**Tags:** scripting\
**Created:** [September 20, 2024, 3:21pm UTC](https://forum.inductiveautomation.com/t/send-receive-message-via-tcp-socket/96240 "2024-09-20T15:21:15Z")\
**Posts on this page:** 1\
**Showing post:** 8

<div class="post-metadata">

**Author:** ![ryan.white](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/ryan.white/32/73193_2.png) [@ryan.white](https://forum.inductiveautomation.com/u/ryan.white)\
**Post date:** [June 6, 2025, 1:00am UTC](https://forum.inductiveautomation.com/t/send-receive-message-via-tcp-socket/96240/8 "2025-06-06T01:00:59Z")

</div>

[javadocs](https://docs.oracle.com/en/java/javase/11/docs/api/java.base/java/net/Socket.html)

Some other posts that may provide insight:

> [@Communicating with external applications over TCP/IP socket /websockets using gateway scripts](https://forum.inductiveautomation.com/t/communicating-with-external-applications-over-tcp-ip-socket-websockets-using-gateway-scripts/20455/10):
>
> Just call all the java stuff from jython. Use jython’s NetBeans shorthand where you can. Something like this (ultra-simplified): from java.net import InetSocketAddress from java.nio import ByteBuffer from java.nio.channels import SocketChannel from java.nio.charset import StandardCharsets def opener(target): parts = target.rsplit(':', 1) if len(parts)\>1: print "Socket Address %s:%s" % (parts[0], parts[1]) sa = InetSocketAddress(parts[0], int(parts[1])) else: print "Socket Address %s…

> [@TCP/IP Client Service](https://forum.inductiveautomation.com/t/tcp-ip-client-service/55118/4):
>
> Something like this: from java.lang import Thread from java.util.concurrent import ConcurrentHashMap g = system.util.persistent("long-lived-thread") # The .setdefault method will not replace an existing key, and # is thread-safe (concurrent). chm = g.setdefault('chm', ConcurrentHashMap()) tagpath = '[default]path/to/boolean/tag' # Rely on closures/globals to make above available in the thread def liveLongAndProsper(): me = Thread.currentThread() # A ConcurrentHashMap's .put() method has th…

---

_[View the full topic](https://forum.inductiveautomation.com/t/send-receive-message-via-tcp-socket/96240)._
