> For the complete documentation index, see [llms.txt](https://hyundai-robotics.gitbook.io/hi6-robot-language/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://hyundai-robotics.gitbook.io/hi6-robot-language/rl-english/external-comm/enet-tcp-udp/enet-tcp-udp-example.md).

# 6.2.5 Examples of TCP and UDP Communication

```python
     import enet
     global msg
     global enet0=enet.ENet() # ENet("tcp") in case of TCP communication

     # port no. 49152–65535 contains dynamic or private ports
     enet0.ip_addr="192.168.1.172"
     enet0.lport=51001 # necessary only in case of UDP communication
     enet0.rport=51002

     enet0.open
     enet0.connect # necessary only in case of TCP communication
     print enet0.state() # normal if it is 1
     enet0.send "hello, "+"udp", 300, "\n"

     enet0.recv msg, 8000 # wait for 8 seconds
     print msg
     delay 1.5
     enet0.close
     print enet0.state() # normal if it is 0
     delay 1.5
     end

```
