<?xml version="1.0" encoding="UTF-8" ?>
<?xml-stylesheet type="text/xsl" href="https://devzone.nordicsemi.com/cfs-file/__key/system/syndication/rss.xsl" media="screen"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:wfw="http://wellformedweb.org/CommentAPI/" xmlns:atom="http://www.w3.org/2005/Atom"><channel><title>Connection Problems to a TCP Server</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/53940/connection-problems-to-a-tcp-server</link><description>Hi, 
 I have a nRF9160DK with a Sim Card from a local provider, that supports NB-IoT. 
 I modified the example program in \ncs\zephyr\samples\net\sockets\echo and wanted to set up a connection from the nRF9160 to my TCP Server. That didn&amp;#39;t work and then</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Wed, 20 Nov 2019 00:55:19 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/53940/connection-problems-to-a-tcp-server" /><item><title>RE: Connection Problems to a TCP Server</title><link>https://devzone.nordicsemi.com/thread/220956?ContentTypeID=1</link><pubDate>Wed, 20 Nov 2019 00:55:19 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:a9b36631-c78b-4605-8d0e-b677e415940f</guid><dc:creator>Simon</dc:creator><description>&lt;p&gt;I am glad you were able to make it work and I am happy to help.&lt;/p&gt;
&lt;p&gt;Best regards,&lt;/p&gt;
&lt;p&gt;Simon&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Connection Problems to a TCP Server</title><link>https://devzone.nordicsemi.com/thread/220893?ContentTypeID=1</link><pubDate>Tue, 19 Nov 2019 14:42:17 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:4dcc314e-9715-489b-a7f8-5a69681664e8</guid><dc:creator>Bergmann</dc:creator><description>&lt;p&gt;I was now able to send data to my TCP server!&lt;/p&gt;
&lt;p&gt;Thanks for your help!&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Connection Problems to a TCP Server</title><link>https://devzone.nordicsemi.com/thread/220704?ContentTypeID=1</link><pubDate>Tue, 19 Nov 2019 04:40:43 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:e7343a4c-aa1e-4918-a1a3-f88d507320cd</guid><dc:creator>Calin M</dc:creator><description>&lt;p&gt;Hi Simon,&lt;/p&gt;
&lt;p&gt;That&amp;#39;s what I was looking for, thanks!&lt;/p&gt;
&lt;p&gt;Calin&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Connection Problems to a TCP Server</title><link>https://devzone.nordicsemi.com/thread/220689?ContentTypeID=1</link><pubDate>Mon, 18 Nov 2019 22:47:05 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:060de7be-59ce-4cc6-a5da-c34679d9c40f</guid><dc:creator>Simon</dc:creator><description>&lt;p&gt;&lt;a href="https://devzone.nordicsemi.com/members/calinm"&gt;Calin M&lt;/a&gt;:&lt;/p&gt;
&lt;p&gt;I wrote a quick sample earlier that demonstrated how to write AT commands from your code:&lt;/p&gt;
&lt;p&gt;&lt;a href="https://devzone.nordicsemi.com/cfs-file/__key/support-attachments/beef5d1b77644c448dabff31668f3a47-98dfa09c0f224812931af64e75ba4ba5/at_5F00_commands_5F00_test.zip"&gt;devzone.nordicsemi.com/.../at_5F00_commands_5F00_test.zip&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;Is this what you are looking for? If not, or if you have more questions, could you open a new ticket? Since this question is unrelated to the initial question.&lt;/p&gt;
&lt;p&gt;Best regards,&lt;/p&gt;
&lt;p&gt;Simon&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Connection Problems to a TCP Server</title><link>https://devzone.nordicsemi.com/thread/220688?ContentTypeID=1</link><pubDate>Mon, 18 Nov 2019 22:39:43 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:626732eb-41ac-40fa-9864-aaf1a33cdef3</guid><dc:creator>Simon</dc:creator><description>[quote user="Weidetracker"]Thanks for your big help![/quote]
&lt;p&gt;No problem, I am always happy to help and I am glad it finally worked out.&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
[quote user="Weidetracker"]So the next step would be to change the connect_to_goolge project so that it connects to my TCP server?[/quote]
&lt;p&gt;Yes, I believe it should be all good now,&amp;nbsp;and that would be the next step yes. If that doesn&amp;#39;t work, you know that the issue is not with the code but your TCP server. Take a look at &lt;a href="https://devzone.nordicsemi.com/f/nordic-q-a/53469/no-message-received-at-udp-server-for-udp_with_psm-sample"&gt;this link&lt;/a&gt;, which talks about port forwarding and how to make the server accessible on the web.&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;Best regards,&lt;/p&gt;
&lt;p&gt;Simon&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Connection Problems to a TCP Server</title><link>https://devzone.nordicsemi.com/thread/220681?ContentTypeID=1</link><pubDate>Mon, 18 Nov 2019 19:31:51 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:5352d78f-cea9-4e6a-bb61-cef135d68ac1</guid><dc:creator>Calin M</dc:creator><description>&lt;p&gt;Hi Simon,&lt;/p&gt;
&lt;p&gt;I&amp;#39;m working on something similar, and I&amp;#39;d like to execute the AT commands when the program starts, rather that typing them into the LTE Link Monitor. Is there a code sample for how to do that?&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;Thanks!&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;Calin&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Connection Problems to a TCP Server</title><link>https://devzone.nordicsemi.com/thread/220680?ContentTypeID=1</link><pubDate>Mon, 18 Nov 2019 19:03:24 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:e621670e-a3e3-487f-9990-fcfb0b3babc4</guid><dc:creator>Bergmann</dc:creator><description>&lt;p&gt;Hey, now I got a connect error: 0&lt;/p&gt;
&lt;p&gt;&lt;img alt=" " src="https://devzone.nordicsemi.com/resized-image/__size/320x240/__key/communityserver-discussions-components-files/4/pastedimage1574103495772v1.png" /&gt;&lt;/p&gt;
[quote userid="72692" url="~/f/nordic-q-a/53940/connection-problems-to-a-tcp-server/219553"]check that &lt;em&gt;blocking_connect()&lt;/em&gt; returns 0)[/quote]
&lt;p&gt;And now I should be connected with the google DNS Server, if I understand this right?&lt;/p&gt;
&lt;p&gt;So the next step would be to change the connect_to_goolge project so that it connects to my TCP server?&lt;/p&gt;
&lt;p&gt;Thanks for your big help!&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Connection Problems to a TCP Server</title><link>https://devzone.nordicsemi.com/thread/220655?ContentTypeID=1</link><pubDate>Mon, 18 Nov 2019 15:30:55 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:c2bea817-bec7-446e-96fc-8142c42b97c7</guid><dc:creator>Simon</dc:creator><description>[quote user="Weidetracker"][/quote]
&lt;p&gt;Is there a way I can use AT+CFUN? for this program? Because I need to make sure, that&amp;nbsp;&lt;/p&gt;
&lt;p&gt;&lt;span style="font-weight:400;"&gt;AT%XSYSTEMMODE=0,1,1,0&amp;nbsp;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="font-weight:400;"&gt;and that&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="font-weight:400;"&gt;&lt;span&gt;AT+CGDCONT=0,&amp;quot;IP&amp;quot;,&amp;quot;m2m.nbiot.t-mobile.at&amp;quot;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;&amp;nbsp;You could try to enable the AT Host library:&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="text"&gt;# AT host library
CONFIG_AT_HOST_LIBRARY=y
CONFIG_UART_INTERRUPT_DRIVEN=y&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;Then open the LTE Link Monitor and type in the AT commands.&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;Could you &lt;a href="https://devzone.nordicsemi.com/nordic/nordic-blog/b/blog/posts/how-to-get-modem-trace-using-trace-collector-in-nrf-connect"&gt;upload a modem trace&lt;/a&gt;? Then we can analyze it and find out the reason for the behavior.&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;Best regards,&lt;/p&gt;
&lt;p&gt;Simon&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Connection Problems to a TCP Server</title><link>https://devzone.nordicsemi.com/thread/220430?ContentTypeID=1</link><pubDate>Sun, 17 Nov 2019 08:56:55 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:d15c2456-fde6-43aa-9778-210fc6128e83</guid><dc:creator>Bergmann</dc:creator><description>&lt;p&gt;No, I still have the problem.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Connection Problems to a TCP Server</title><link>https://devzone.nordicsemi.com/thread/220285?ContentTypeID=1</link><pubDate>Fri, 15 Nov 2019 11:51:54 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:8d7937b0-bfba-477a-8e05-249b3d89bb2a</guid><dc:creator>Simon</dc:creator><description>&lt;p&gt;I am sorry for the delay, I&amp;#39;ve been quite busy lately. Have you been able to resolve the issue?&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Connection Problems to a TCP Server</title><link>https://devzone.nordicsemi.com/thread/219708?ContentTypeID=1</link><pubDate>Tue, 12 Nov 2019 14:21:45 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:7282ec5f-ca50-4395-beec-89ef1228fcef</guid><dc:creator>Bergmann</dc:creator><description>&lt;p&gt;Hi I added&amp;nbsp;&lt;/p&gt;
&lt;p&gt;CONFIG_LTE_PDP_CONTEXT=&amp;quot;0,\&amp;quot;IP\&amp;quot;,\&amp;quot;m2m.nbiot.t-mobile.at\&amp;quot;&amp;quot;&lt;br /&gt;CONFIG_LTE_LEGACY_PCO_MODE=y&lt;br /&gt;CONFIG_NRF_CLOUD_STATIC_IPV4=y&lt;br /&gt;CONFIG_LTE_NETWORK_MODE_NBIOT_GPS=y&lt;br /&gt;CONFIG_LTE_NETWORK_MODE_LTE_M_GPS=n&lt;/p&gt;
&lt;p&gt;to the prj.conf file. And then i got the error messages:&amp;nbsp;&lt;/p&gt;
&lt;p&gt;&lt;img src="https://devzone.nordicsemi.com/resized-image/__size/320x240/__key/communityserver-discussions-components-files/4/pastedimage1573568224416v1.png" alt=" " /&gt;&lt;/p&gt;
&lt;p&gt;&lt;a href="https://devzone.nordicsemi.com/cfs-file/__key/communityserver-discussions-components-files/4/2019_2D00_11_2D00_12T14_5F00_13_5F00_04.792Z_2D00_log.txt"&gt;devzone.nordicsemi.com/.../2019_2D00_11_2D00_12T14_5F00_13_5F00_04.792Z_2D00_log.txt&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;Is there a way I can use AT+CFUN? for this program? Because I need to make sure, that&amp;nbsp;&lt;/p&gt;
&lt;p&gt;&lt;span style="font-weight:400;"&gt;AT%XSYSTEMMODE=0,1,1,0&amp;nbsp;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="font-weight:400;"&gt;and that&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="font-weight:400;"&gt;&lt;span&gt;AT+CGDCONT=0,&amp;quot;IP&amp;quot;,&amp;quot;m2m.nbiot.t-mobile.at&amp;quot;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="font-weight:400;"&gt;&lt;span&gt;Otherwise there won&amp;#39;t be a connection.&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="font-weight:400;"&gt;&lt;span&gt;Thanks for your help and your time!&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Connection Problems to a TCP Server</title><link>https://devzone.nordicsemi.com/thread/219553?ContentTypeID=1</link><pubDate>Mon, 11 Nov 2019 21:54:54 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:d0d12874-2f99-4922-ba58-f8cbf7388ec6</guid><dc:creator>Simon</dc:creator><description>&lt;p&gt;&lt;a href="https://devzone.nordicsemi.com/cfs-file/__key/support-attachments/beef5d1b77644c448dabff31668f3a47-98dfa09c0f224812931af64e75ba4ba5/3010.connect_5F00_to_5F00_google.zip"&gt;devzone.nordicsemi.com/.../3010.connect_5F00_to_5F00_google.zip&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;See if you are able to&amp;nbsp;connect with this example (check that &lt;em&gt;blocking_connect()&lt;/em&gt; returns 0). It worked on my nRF91 DK.&lt;/p&gt;
&lt;p&gt;Best regards,&lt;/p&gt;
&lt;p&gt;Simon&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Connection Problems to a TCP Server</title><link>https://devzone.nordicsemi.com/thread/218949?ContentTypeID=1</link><pubDate>Thu, 07 Nov 2019 05:36:32 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:e69504a2-f98d-4333-bea5-843d4556cf4c</guid><dc:creator>Bergmann</dc:creator><description>&lt;p&gt;Ok, i changed the IP address and the port:&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="c_cpp"&gt;#include &amp;lt;errno.h&amp;gt;
#include &amp;lt;stdio.h&amp;gt;
#include &amp;lt;net/bsdlib.h&amp;gt;
#include &amp;lt;kernel.h&amp;gt;
#include &amp;lt;net/socket.h&amp;gt;
#include &amp;lt;at_cmd.h&amp;gt;
#include &amp;lt;lte_lc.h&amp;gt;

#define PORT 80
#define IPADDR &amp;quot;216.58.208.110&amp;quot;

#include &amp;lt;logging/log.h&amp;gt;

/* Initialize module-specific magic state (once per module name): */
LOG_MODULE_REGISTER();

int clientInit()
{
    int fd, ret;
    struct sockaddr_in bind_addr;

    fd = socket(AF_INET, SOCK_STREAM, IPPROTO_TCP);
    if (fd &amp;lt; 0) {
        printk(&amp;quot;error: socket: %d\n&amp;quot;, errno);
        return -1;
    } else {
		printk(&amp;quot;Socket successfully created!\n&amp;quot;);
	}

    bind_addr.sin_family = AF_INET;
	inet_pton(AF_INET, IPADDR, &amp;amp;bind_addr.sin_addr.s_addr);
    bind_addr.sin_port = htons(PORT);

	if (bind(fd, (struct sockaddr *)&amp;amp;bind_addr, sizeof(bind_addr)) &amp;lt; 0) {
		printf(&amp;quot;error: bind: %d\n&amp;quot;, errno);
		exit(1);
	}

	ret = connect(fd, (struct sockaddr*)&amp;amp;bind_addr, sizeof(bind_addr));
	if (ret &amp;lt; 0) {
		printk(&amp;quot;ERROR CONNECTING RET: %d ERRNO: %d\n&amp;quot;, ret, errno);
        return ret;
	}
    return fd;
}

static void modem_configure(void)
{
#if defined(CONFIG_LTE_LINK_CONTROL)
	if (IS_ENABLED(CONFIG_LTE_AUTO_INIT_AND_CONNECT)) {
		/* Do nothing, modem is already turned on
		 * and connected.
		 */
	} else {
		int err;

		printk(&amp;quot;LTE Link Connecting ...\n&amp;quot;);
		err = lte_lc_init_and_connect();
		__ASSERT(err == 0, &amp;quot;LTE link could not be established.&amp;quot;);
		printk(&amp;quot;LTE Link Connected!\n&amp;quot;);
	}
#endif
}

int main(void) {

    printk(&amp;quot;Modem Configure\n&amp;quot;);
    modem_configure();

    int fd = clientInit();
    if (fd &amp;lt; 0) {
        printk(&amp;quot;Client Init err %d\n&amp;quot;, fd);
        return fd;
    }

    char buf[] = &amp;quot;Hallo Welt!\n&amp;quot;;

    int out_len = send(fd, buf, sizeof(buf), 0);
    if (out_len &amp;lt; 0) {
        printk(&amp;quot;error: send: %d\n&amp;quot;, errno);
    }

	while (1) {
		k_sleep(500);
        printk(&amp;quot;Waiting...\n&amp;quot;);
	}
}&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;And then I flashed the code to the nRF9160, but there is the same error again:&lt;/p&gt;
&lt;p&gt;&lt;a href="https://devzone.nordicsemi.com/cfs-file/__key/communityserver-discussions-components-files/4/2019_2D00_11_2D00_07T05_5F00_19_5F00_34.270Z_2D00_log.txt"&gt;devzone.nordicsemi.com/.../2019_2D00_11_2D00_07T05_5F00_19_5F00_34.270Z_2D00_log.txt&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;Does that mean, that the code should be ok, if it works at your location?&lt;/p&gt;
&lt;p&gt;&lt;br /&gt;Might there be some problems with the Sim Card? I already tested it with another Board from my local provider (Board: SARA AFF N211). He provided a tutorial for that and that worked fine to connect to his IoT Gateway Server with another APN.&lt;/p&gt;
&lt;p&gt;By the way, I never got into nRF Cloud. I also have connection problems there, but I couldn&amp;rsquo;t fix them yet: &lt;a href="https://devzone.nordicsemi.com/f/nordic-q-a/48859/nrf9160-dk-connecting-problems-with-nrf-cloud"&gt;devzone.nordicsemi.com/.../nrf9160-dk-connecting-problems-with-nrf-cloud&lt;/a&gt; So I tried to set up the connection directly to the TCP Server (what would be the final goal) and skip the connection process to nRF Cloud.&lt;/p&gt;
&lt;p&gt;&lt;br /&gt;What do you think about this problem, do you have any further ideas?&lt;/p&gt;
&lt;p&gt;&lt;br /&gt;Thanks for your answers and your help!&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Connection Problems to a TCP Server</title><link>https://devzone.nordicsemi.com/thread/218878?ContentTypeID=1</link><pubDate>Wed, 06 Nov 2019 15:21:11 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:de77ed3a-fdbd-4b98-b43b-fb738d206964</guid><dc:creator>Simon</dc:creator><description>&lt;p&gt;I modified your example, by changing the IP address to&amp;nbsp;&lt;span&gt;216.58.208.110 (IP address of google.com) and the port to 80, and I was able to connect successfully. Are you sure your server is exposed to the public internet? Try creating a client with&amp;nbsp;&lt;a href="https://sourceforge.net/projects/sockettest/"&gt;SocketTest&lt;/a&gt;&amp;nbsp;and connect to the server.&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;Check out &lt;a href="https://devzone.nordicsemi.com/f/nordic-q-a/53469/no-message-received-at-udp-server-for-udp_with_psm-sample"&gt;this thread&lt;/a&gt; as well, which may help you.&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;Best regards,&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;Simon&lt;/span&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Connection Problems to a TCP Server</title><link>https://devzone.nordicsemi.com/thread/218640?ContentTypeID=1</link><pubDate>Tue, 05 Nov 2019 15:09:29 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:5999dd6a-9526-4d64-b1a1-f72d46826e89</guid><dc:creator>Bergmann</dc:creator><description>&lt;p&gt;Hi, i tried it with this code now:&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="c_cpp"&gt;#include &amp;lt;errno.h&amp;gt;
#include &amp;lt;stdio.h&amp;gt;
#include &amp;lt;net/bsdlib.h&amp;gt;
#include &amp;lt;kernel.h&amp;gt;
#include &amp;lt;net/socket.h&amp;gt;
#include &amp;lt;at_cmd.h&amp;gt;
#include &amp;lt;lte_lc.h&amp;gt;

#define PORT 22
#define IPADDR &amp;quot;8.8.8.8&amp;quot;

#include &amp;lt;logging/log.h&amp;gt;

/* Initialize module-specific magic state (once per module name): */
LOG_MODULE_REGISTER();

int clientInit()
{
    int fd, ret;
    struct sockaddr_in bind_addr;

    fd = socket(AF_INET, SOCK_STREAM, IPPROTO_TCP);
    if (fd &amp;lt; 0) {
        printk(&amp;quot;error: socket: %d\n&amp;quot;, errno);
        return -1;
    } else {
		printk(&amp;quot;Socket successfully created!\n&amp;quot;);
	}

    bind_addr.sin_family = AF_INET;
	inet_pton(AF_INET, IPADDR, &amp;amp;bind_addr.sin_addr.s_addr);
    bind_addr.sin_port = htons(PORT);

	if (bind(fd, (struct sockaddr *)&amp;amp;bind_addr, sizeof(bind_addr)) &amp;lt; 0) {
		printf(&amp;quot;error: bind: %d\n&amp;quot;, errno);
		exit(1);
	}

	ret = connect(fd, (struct sockaddr*)&amp;amp;bind_addr, sizeof(bind_addr));
	if (ret &amp;lt; 0) {
		printk(&amp;quot;ERROR CONNECTING RET: %d ERRNO: %d\n&amp;quot;, ret, errno);
        return ret;
	}
    return fd;
}

static void modem_configure(void)
{
#if defined(CONFIG_LTE_LINK_CONTROL)
	if (IS_ENABLED(CONFIG_LTE_AUTO_INIT_AND_CONNECT)) {
		/* Do nothing, modem is already turned on
		 * and connected.
		 */
	} else {
		int err;

		printk(&amp;quot;LTE Link Connecting ...\n&amp;quot;);
		err = lte_lc_init_and_connect();
		__ASSERT(err == 0, &amp;quot;LTE link could not be established.&amp;quot;);
		printk(&amp;quot;LTE Link Connected!\n&amp;quot;);
	}
#endif
}

int main(void) {

    printk(&amp;quot;Modem Configure\n&amp;quot;);
    modem_configure();

    int fd = clientInit();
    if (fd &amp;lt; 0) {
        printk(&amp;quot;Client Init err %d\n&amp;quot;, fd);
        return fd;
    }

    char buf[] = &amp;quot;Hallo Welt!\n&amp;quot;;

    int out_len = send(fd, buf, sizeof(buf), 0);
    if (out_len &amp;lt; 0) {
        printk(&amp;quot;error: send: %d\n&amp;quot;, errno);
    }

	while (1) {
		k_sleep(500);
        printk(&amp;quot;Waiting...\n&amp;quot;);
	}
}
&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;But I still get an error like this:&lt;/p&gt;
&lt;p&gt;&lt;img src="https://devzone.nordicsemi.com/resized-image/__size/320x240/__key/communityserver-discussions-components-files/4/pastedimage1572966197068v1.png" alt=" " /&gt;&lt;/p&gt;
&lt;p&gt;&lt;a href="https://devzone.nordicsemi.com/cfs-file/__key/communityserver-discussions-components-files/4/2019_2D00_11_2D00_05T14_5F00_58_5F00_52.883Z_2D00_log.txt"&gt;devzone.nordicsemi.com/.../2019_2D00_11_2D00_05T14_5F00_58_5F00_52.883Z_2D00_log.txt&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;I really would appreciate it, if you could take a closer look/ask somebody with more knowledge, because I am out of ideas on what could be the cause of the issue.&lt;/p&gt;
&lt;p&gt;Thanks for your time and your help!&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Connection Problems to a TCP Server</title><link>https://devzone.nordicsemi.com/thread/218247?ContentTypeID=1</link><pubDate>Mon, 04 Nov 2019 13:52:22 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:2dd4caba-6b1c-4e7f-beef-96d9ad01fbf9</guid><dc:creator>Simon</dc:creator><description>&lt;p&gt;I don&amp;#39;t have full knowledge about this, but don&amp;#39;t you&amp;nbsp;need to bind the file descriptor with the address using &lt;em&gt;bind()&lt;/em&gt; ( between&lt;em&gt; socket()&lt;/em&gt; and &lt;em&gt;connect()&lt;/em&gt;)? Try this and see if it works then.&lt;/p&gt;
&lt;p&gt;If you still have problems, I will take a closer look at your issue/ask somebody with more knowledge about it.&lt;/p&gt;
&lt;p&gt;Best regards,&lt;/p&gt;
&lt;p&gt;Simon&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>