# Creating a TCP/IP socket connection

**URL:** <https://forum.legato.io/t/creating-a-tcp-ip-socket-connection/4024>\
**Category:** Legato Linux distribution (Yocto project)\
**Created:** [January 15, 2019, 5:56pm UTC](https://forum.legato.io/t/creating-a-tcp-ip-socket-connection/4024 "2019-01-15T17:56:10Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![vishalgore](https://avatars.discourse-cdn.com/v4/letter/v/ce73a5/32.png) [@vishalgore](https://forum.legato.io/u/vishalgore)\
**Post date:** [January 15, 2019, 5:56pm UTC](https://forum.legato.io/t/creating-a-tcp-ip-socket-connection/4024/1 "2019-01-15T17:56:11Z")

</div>

Hi,  
i want to connect my legato board to server using TCP/IP socket to send my data to server.Can someone guide me to do that?

Thanks

---

<div class="post-metadata">

**Author:** ![prushp](https://sea1.discourse-cdn.com/flex019/user_avatar/forum.legato.io/prushp/32/408_2.png) [@prushp](https://forum.legato.io/u/prushp)\
**Post date:** [January 15, 2019, 8:34pm UTC](https://forum.legato.io/t/creating-a-tcp-ip-socket-connection/4024/2 "2019-01-15T20:34:30Z")

</div>

Do you have a data connection to outside world? The programmatic way to get an IP connection is to use the api - le\_data\_Request().

To begin with, I would probably use a tool - “cm data connect” and see if I can get an interface such as rmnet\_data0 with correct ip address etc., once I have a valid ip address, I would ping to the server and make sure that succeeds. Then you can use any socket programming example online to connect to your server.

---

<div class="post-metadata">

**Author:** ![jyijyi](https://sea1.discourse-cdn.com/flex019/user_avatar/forum.legato.io/jyijyi/32/822_2.png) [@jyijyi](https://forum.legato.io/u/jyijyi)\
**Post date:** [January 16, 2019, 1:47am UTC](https://forum.legato.io/t/creating-a-tcp-ip-socket-connection/4024/3 "2019-01-16T01:47:41Z")

</div>

Here is example to use command line:  
root@swi-mdm9x28:~# cm data connect &  
root@swi-mdm9x28:~#  
root@swi-mdm9x28:~# Setting up profile 1  
Setting access point name … ok  
Setting packet data protocol … ok  
Setting Authentication … ok  
Connecting … ok  
Checking if device is up … ok  
Routing … ok  
Updating /etc/resolv.conf … ok  
Updating /etc/resolv.conf … ok  
Testing connection … ok

[1]+ Done cm data connect  
root@swi-mdm9x28:~#  
root@swi-mdm9x28:~# nc 123.123.123.123 5044

asdf

asdf
