<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: Socket creation in LPC Microcontrollers</title>
    <link>https://community.nxp.com/t5/LPC-Microcontrollers/Socket-creation/m-p/1610414#M51822</link>
    <description>&lt;P&gt;Hi，&lt;/P&gt;
&lt;P&gt;For Ethernet module, we use the LWIP stack, I suppose that the LWIP stack does not support socket mechanism, the socket mechanism is used in Linux.&lt;/P&gt;
&lt;P&gt;The SDK example provides the http_srv example, pls refer to it.&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="xiangjun_rong_0-1678155903660.png" style="width: 400px;"&gt;&lt;img src="https://community.nxp.com/t5/image/serverpage/image-id/213381i3380139816105D51/image-size/medium?v=v2&amp;amp;px=400" role="button" title="xiangjun_rong_0-1678155903660.png" alt="xiangjun_rong_0-1678155903660.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;In the example, the LPC54018 functions as a server.&lt;/P&gt;
&lt;P&gt;Hope it can help you&lt;/P&gt;
&lt;P&gt;BR&lt;/P&gt;
&lt;P&gt;XiangJun Rong&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Tue, 07 Mar 2023 02:26:52 GMT</pubDate>
    <dc:creator>xiangjun_rong</dc:creator>
    <dc:date>2023-03-07T02:26:52Z</dc:date>
    <item>
      <title>Socket creation</title>
      <link>https://community.nxp.com/t5/LPC-Microcontrollers/Socket-creation/m-p/1609805#M51810</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;i am using lpc54s018 i am trying to create socket programming but i am getting socket creation failed so&amp;nbsp; please help me what the main reason&amp;nbsp; for that is&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks&amp;nbsp;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 06 Mar 2023 07:27:35 GMT</pubDate>
      <guid>https://community.nxp.com/t5/LPC-Microcontrollers/Socket-creation/m-p/1609805#M51810</guid>
      <dc:creator>sachinn434</dc:creator>
      <dc:date>2023-03-06T07:27:35Z</dc:date>
    </item>
    <item>
      <title>Re: Socket creation</title>
      <link>https://community.nxp.com/t5/LPC-Microcontrollers/Socket-creation/m-p/1610414#M51822</link>
      <description>&lt;P&gt;Hi，&lt;/P&gt;
&lt;P&gt;For Ethernet module, we use the LWIP stack, I suppose that the LWIP stack does not support socket mechanism, the socket mechanism is used in Linux.&lt;/P&gt;
&lt;P&gt;The SDK example provides the http_srv example, pls refer to it.&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="xiangjun_rong_0-1678155903660.png" style="width: 400px;"&gt;&lt;img src="https://community.nxp.com/t5/image/serverpage/image-id/213381i3380139816105D51/image-size/medium?v=v2&amp;amp;px=400" role="button" title="xiangjun_rong_0-1678155903660.png" alt="xiangjun_rong_0-1678155903660.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;In the example, the LPC54018 functions as a server.&lt;/P&gt;
&lt;P&gt;Hope it can help you&lt;/P&gt;
&lt;P&gt;BR&lt;/P&gt;
&lt;P&gt;XiangJun Rong&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 07 Mar 2023 02:26:52 GMT</pubDate>
      <guid>https://community.nxp.com/t5/LPC-Microcontrollers/Socket-creation/m-p/1610414#M51822</guid>
      <dc:creator>xiangjun_rong</dc:creator>
      <dc:date>2023-03-07T02:26:52Z</dc:date>
    </item>
    <item>
      <title>Re: Socket creation</title>
      <link>https://community.nxp.com/t5/LPC-Microcontrollers/Socket-creation/m-p/1617967#M51947</link>
      <description>&lt;P&gt;hi,&lt;/P&gt;&lt;P&gt;thanks for reply but i am using&amp;nbsp; tcpecho_raw_init(); for tcip client and server connection but tcpsend and tcpreceive&amp;nbsp; is not going continuously&amp;nbsp;&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;&lt;P&gt;/*&lt;BR /&gt;* Copyright (c) 2001-2004 Swedish Institute of Computer Science.&lt;BR /&gt;* All rights reserved.&lt;BR /&gt;*&lt;BR /&gt;* Redistribution and use in source and binary forms, with or without modification,&lt;BR /&gt;* are permitted provided that the following conditions are met:&lt;BR /&gt;*&lt;BR /&gt;* 1. Redistributions of source code must retain the above copyright notice,&lt;BR /&gt;* this list of conditions and the following disclaimer.&lt;BR /&gt;* 2. Redistributions in binary form must reproduce the above copyright notice,&lt;BR /&gt;* this list of conditions and the following disclaimer in the documentation&lt;BR /&gt;* and/or other materials provided with the distribution.&lt;BR /&gt;* 3. The name of the author may not be used to endorse or promote products&lt;BR /&gt;* derived from this software without specific prior written permission.&lt;BR /&gt;*&lt;BR /&gt;* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED&lt;BR /&gt;* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF&lt;BR /&gt;* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT&lt;BR /&gt;* SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,&lt;BR /&gt;* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT&lt;BR /&gt;* OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS&lt;BR /&gt;* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN&lt;BR /&gt;* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING&lt;BR /&gt;* IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY&lt;BR /&gt;* OF SUCH DAMAGE.&lt;BR /&gt;*&lt;BR /&gt;* This file is part of and a contribution to the lwIP TCP/IP stack.&lt;BR /&gt;*&lt;BR /&gt;* Credits go to Adam Dunkels (and the current maintainers) of this software.&lt;BR /&gt;*&lt;BR /&gt;* Christiaan Simons rewrote this file to get a more stable echo example.&lt;BR /&gt;*/&lt;/P&gt;&lt;P&gt;/**&lt;BR /&gt;* @file&lt;BR /&gt;* TCP echo server example using raw API.&lt;BR /&gt;*&lt;BR /&gt;* Echos all bytes sent by connecting client,&lt;BR /&gt;* and passively closes when client is done.&lt;BR /&gt;*&lt;BR /&gt;*/&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;#include "lwip/opt.h"&lt;BR /&gt;#include "lwip/debug.h"&lt;BR /&gt;#include "lwip/stats.h"&lt;BR /&gt;#include "lwip/tcp.h"&lt;BR /&gt;#include "tcpecho_raw.h"&lt;BR /&gt;#include&amp;lt;string.h&amp;gt;&lt;BR /&gt;#include&amp;lt;stdlib.h&amp;gt;&lt;BR /&gt;#include&amp;lt;stdio.h&amp;gt;&lt;BR /&gt;#include "fsl_usart.h"&lt;BR /&gt;#include "fsl_debug_console.h"&lt;BR /&gt;//#include"USART_HEADER.h"&lt;BR /&gt;#include&amp;lt;string.h&amp;gt;&lt;BR /&gt;#include "lwip/sys.h"&lt;BR /&gt;/* FreeRTOS kernel includes. */&lt;BR /&gt;//#include "FreeRTOS.h"&lt;BR /&gt;//#include "task.h"&lt;BR /&gt;//#include "queue.h"&lt;BR /&gt;//#include "timers.h"&lt;BR /&gt;#define BUFFER_SIZE 256&lt;BR /&gt;int flag=0;&lt;BR /&gt;uint8_t Udatabuf[]=" ";&lt;BR /&gt;uint8_t buffer[BUFFER_SIZE];&lt;BR /&gt;static volatile bool closing = false;&lt;BR /&gt;#if LWIP_TCP&lt;BR /&gt;static struct tcp_pcb *tcpecho_raw_pcb;&lt;BR /&gt;void connected_callback(void *arg, struct tcp_pcb *tpcb, err_t err);&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;/*! @brief Stack size of the temporary lwIP initialization thread. */&lt;BR /&gt;#define INIT_THREAD_STACKSIZE 1024&lt;/P&gt;&lt;P&gt;/*! @brief Priority of the temporary lwIP initialization thread. */&lt;BR /&gt;#define INIT_THREAD_PRIO DEFAULT_THREAD_PRIO&lt;/P&gt;&lt;P&gt;/*! @brief Stack size of the thread which prints DHCP info. */&lt;BR /&gt;#define PRINT_THREAD_STACKSIZE 512&lt;/P&gt;&lt;P&gt;/*! @brief Priority of the thread which prints DHCP info. */&lt;BR /&gt;#define PRINT_THREAD_PRIO DEFAULT_THREAD_PRIO&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;enum tcpecho_raw_states&lt;BR /&gt;{&lt;BR /&gt;ES_NONE = 0,&lt;BR /&gt;ES_ACCEPTED,&lt;BR /&gt;ES_RECEIVED,&lt;BR /&gt;ES_CLOSING&lt;BR /&gt;};&lt;/P&gt;&lt;P&gt;struct tcpecho_raw_state&lt;BR /&gt;{&lt;BR /&gt;u8_t state;&lt;BR /&gt;u8_t retries;&lt;BR /&gt;struct tcp_pcb *pcb;&lt;BR /&gt;/* pbuf (chain) to recycle */&lt;BR /&gt;struct pbuf *p;&lt;BR /&gt;};&lt;/P&gt;&lt;P&gt;static void&lt;BR /&gt;tcpecho_raw_free(struct tcpecho_raw_state *es)&lt;BR /&gt;{&lt;BR /&gt;if (es != NULL) {&lt;BR /&gt;if (es-&amp;gt;p) {&lt;BR /&gt;/* free the buffer chain if present */&lt;BR /&gt;pbuf_free(es-&amp;gt;p);&lt;BR /&gt;}&lt;/P&gt;&lt;P&gt;mem_free(es);&lt;BR /&gt;}&lt;BR /&gt;}&lt;/P&gt;&lt;P&gt;static void&lt;BR /&gt;tcpecho_raw_close(struct tcp_pcb *tpcb, struct tcpecho_raw_state *es)&lt;BR /&gt;{&lt;BR /&gt;tcp_arg(tpcb, NULL);&lt;BR /&gt;tcp_sent(tpcb, NULL);&lt;BR /&gt;tcp_recv(tpcb, NULL);&lt;BR /&gt;tcp_err(tpcb, NULL);&lt;BR /&gt;tcp_poll(tpcb, NULL, 0);&lt;/P&gt;&lt;P&gt;tcpecho_raw_free(es);&lt;/P&gt;&lt;P&gt;tcp_close(tpcb);&lt;BR /&gt;}&lt;/P&gt;&lt;P&gt;static void&lt;BR /&gt;tcpecho_raw_send(struct tcp_pcb *tpcb, struct tcpecho_raw_state *es)&lt;BR /&gt;{&lt;/P&gt;&lt;P&gt;struct pbuf *ptr;&lt;BR /&gt;err_t wr_err = ERR_OK;&lt;BR /&gt;&lt;BR /&gt;while ((wr_err == ERR_OK) &amp;amp;&amp;amp;&lt;BR /&gt;(es-&amp;gt;p != NULL) &amp;amp;&amp;amp;&lt;BR /&gt;(es-&amp;gt;p-&amp;gt;len &amp;lt;= tcp_sndbuf(tpcb))) {&lt;BR /&gt;ptr = es-&amp;gt;p;&lt;/P&gt;&lt;P&gt;/* enqueue data for transmission */&lt;BR /&gt;wr_err = tcp_write(tpcb, ptr-&amp;gt;payload, ptr-&amp;gt;len, 1);&lt;/P&gt;&lt;P&gt;PRINTF(" the pay load is sent %s",ptr-&amp;gt;payload);&lt;/P&gt;&lt;P&gt;PRINTF("\r\n");&lt;/P&gt;&lt;P&gt;if (wr_err == ERR_OK) {&lt;BR /&gt;u16_t plen;&lt;/P&gt;&lt;P&gt;plen = ptr-&amp;gt;len;&lt;BR /&gt;/* continue with next pbuf in chain (if any) */&lt;BR /&gt;es-&amp;gt;p = ptr-&amp;gt;next;&lt;BR /&gt;if(es-&amp;gt;p != NULL) {&lt;BR /&gt;/* new reference! */&lt;BR /&gt;pbuf_ref(es-&amp;gt;p);&lt;BR /&gt;}&lt;BR /&gt;/* chop first pbuf from chain */&lt;BR /&gt;pbuf_free(ptr);&lt;BR /&gt;/* we can read more data now */&lt;BR /&gt;tcp_recved(tpcb, plen);&lt;BR /&gt;} else if(wr_err == ERR_MEM) {&lt;BR /&gt;/* we are low on memory, try later / harder, defer to poll */&lt;BR /&gt;es-&amp;gt;p = ptr;&lt;BR /&gt;} else {&lt;BR /&gt;/* other problem ?? */&lt;BR /&gt;}&lt;BR /&gt;}&lt;BR /&gt;}&lt;/P&gt;&lt;P&gt;static void&lt;BR /&gt;tcpecho_raw_error(void *arg, err_t err)&lt;BR /&gt;{&lt;BR /&gt;struct tcpecho_raw_state *es;&lt;/P&gt;&lt;P&gt;LWIP_UNUSED_ARG(err);&lt;/P&gt;&lt;P&gt;es = (struct tcpecho_raw_state *)arg;&lt;/P&gt;&lt;P&gt;tcpecho_raw_free(es);&lt;BR /&gt;}&lt;/P&gt;&lt;P&gt;static err_t&lt;BR /&gt;tcpecho_raw_poll(void *arg, struct tcp_pcb *tpcb)&lt;BR /&gt;{&lt;BR /&gt;err_t ret_err;&lt;BR /&gt;struct tcpecho_raw_state *es;&lt;/P&gt;&lt;P&gt;es = (struct tcpecho_raw_state *)arg;&lt;BR /&gt;if (es != NULL) {&lt;BR /&gt;if (es-&amp;gt;p != NULL) {&lt;BR /&gt;/* there is a remaining pbuf (chain) */&lt;BR /&gt;tcpecho_raw_send(tpcb, es);&lt;BR /&gt;} else {&lt;BR /&gt;/* no remaining pbuf (chain) */&lt;BR /&gt;if(es-&amp;gt;state == ES_CLOSING) {&lt;BR /&gt;tcpecho_raw_close(tpcb, es);&lt;BR /&gt;}&lt;BR /&gt;}&lt;BR /&gt;ret_err = ERR_OK;&lt;BR /&gt;} else {&lt;BR /&gt;/* nothing to be done */&lt;BR /&gt;tcp_abort(tpcb);&lt;BR /&gt;ret_err = ERR_ABRT;&lt;BR /&gt;}&lt;BR /&gt;return ret_err;&lt;BR /&gt;}&lt;/P&gt;&lt;P&gt;static err_t&lt;BR /&gt;tcpecho_raw_sent(void *arg, struct tcp_pcb *tpcb, u16_t len)&lt;BR /&gt;{&lt;/P&gt;&lt;P&gt;struct tcpecho_raw_state *es;&lt;/P&gt;&lt;P&gt;LWIP_UNUSED_ARG(len);&lt;/P&gt;&lt;P&gt;es = (struct tcpecho_raw_state *)arg;&lt;BR /&gt;es-&amp;gt;retries = 0;&lt;/P&gt;&lt;P&gt;if(es-&amp;gt;p != NULL) {&lt;/P&gt;&lt;P&gt;/* still got pbufs to send */&lt;BR /&gt;tcp_sent(tpcb, tcpecho_raw_sent);&lt;BR /&gt;tcpecho_raw_send(tpcb, es);&lt;/P&gt;&lt;P&gt;} else {&lt;BR /&gt;/* no more pbufs to send */&lt;BR /&gt;if(es-&amp;gt;state == ES_CLOSING) {&lt;BR /&gt;tcpecho_raw_close(tpcb, es);&lt;BR /&gt;}&lt;BR /&gt;}&lt;BR /&gt;return ERR_OK;&lt;BR /&gt;}&lt;/P&gt;&lt;P&gt;static err_t&lt;BR /&gt;tcpecho_raw_recv(void *arg, struct tcp_pcb *tpcb, struct pbuf *p, err_t err)&lt;BR /&gt;{&lt;/P&gt;&lt;P&gt;struct tcpecho_raw_state *es;&lt;BR /&gt;err_t ret_err;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;PRINTF("RECEIVED DATA = %d %s\n",p-&amp;gt;len,p-&amp;gt;payload);&lt;/P&gt;&lt;P&gt;// not printing this second time it is not print ?&lt;/P&gt;&lt;P&gt;LWIP_ASSERT("arg != NULL",arg != NULL);&lt;BR /&gt;es = (struct tcpecho_raw_state *)arg;&lt;/P&gt;&lt;P&gt;if (p == NULL) {&lt;BR /&gt;/* remote host closed connection */&lt;BR /&gt;PRINTF("P is NULL");&lt;BR /&gt;es-&amp;gt;state = ES_CLOSING;&lt;/P&gt;&lt;P&gt;if(es-&amp;gt;p == NULL) {&lt;BR /&gt;PRINTF("es-&amp;gt;p NULL");&lt;BR /&gt;/* we're done sending, close it */&lt;BR /&gt;tcpecho_raw_close(tpcb, es);&lt;BR /&gt;} else {&lt;BR /&gt;/* we're not done yet */&lt;BR /&gt;tcpecho_raw_send(tpcb, es);&lt;BR /&gt;}&lt;BR /&gt;ret_err = ERR_OK;&lt;BR /&gt;} else if(err != ERR_OK) {&lt;BR /&gt;/* cleanup, for unknown reason */&lt;BR /&gt;if (p != NULL) {&lt;BR /&gt;pbuf_free(p);&lt;BR /&gt;PRINTF("pbuf_freeL");&lt;BR /&gt;}&lt;BR /&gt;ret_err = err;&lt;BR /&gt;}&lt;BR /&gt;else if(es-&amp;gt;state == ES_ACCEPTED) {&lt;BR /&gt;/* first data chunk in p-&amp;gt;payload */&lt;BR /&gt;es-&amp;gt;state = ES_RECEIVED;&lt;BR /&gt;/* store reference to incoming pbuf (chain) */&lt;BR /&gt;es-&amp;gt;p = p;&lt;BR /&gt;tcpecho_raw_send(tpcb, es);&lt;BR /&gt;ret_err = ERR_OK;&lt;BR /&gt;} else if (es-&amp;gt;state == ES_RECEIVED) {&lt;BR /&gt;/* read some more data */&lt;BR /&gt;if(es-&amp;gt;p == NULL) {&lt;BR /&gt;es-&amp;gt;p = p;&lt;BR /&gt;tcpecho_raw_send(tpcb, es);&lt;BR /&gt;} else {&lt;BR /&gt;struct pbuf *ptr;&lt;/P&gt;&lt;P&gt;/* chain pbufs to the end of what we recv'ed previously */&lt;BR /&gt;ptr = es-&amp;gt;p;&lt;BR /&gt;pbuf_cat(ptr,p);&lt;BR /&gt;}&lt;BR /&gt;ret_err = ERR_OK;&lt;BR /&gt;} else {&lt;BR /&gt;/* unkown es-&amp;gt;state, trash data */&lt;BR /&gt;tcp_recved(tpcb, p-&amp;gt;tot_len);&lt;BR /&gt;pbuf_free(p);&lt;BR /&gt;ret_err = ERR_OK;&lt;BR /&gt;}&lt;BR /&gt;return ret_err;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;}&lt;/P&gt;&lt;P&gt;static err_t&lt;BR /&gt;tcpecho_raw_accept(void *arg, struct tcp_pcb *newpcb, err_t err)&lt;BR /&gt;{&lt;BR /&gt;err_t ret_err;&lt;BR /&gt;struct tcpecho_raw_state *es;&lt;/P&gt;&lt;P&gt;LWIP_UNUSED_ARG(arg);&lt;BR /&gt;if ((err != ERR_OK) || (newpcb == NULL)) {&lt;BR /&gt;return ERR_VAL;&lt;BR /&gt;}&lt;/P&gt;&lt;P&gt;/* Unless this pcb should have NORMAL priority, set its priority now.&lt;BR /&gt;When running out of pcbs, low priority pcbs can be aborted to create&lt;BR /&gt;new pcbs of higher priority. */&lt;BR /&gt;tcp_setprio(newpcb, TCP_PRIO_MIN);&lt;/P&gt;&lt;P&gt;es = (struct tcpecho_raw_state *)mem_malloc(sizeof(struct tcpecho_raw_state));&lt;BR /&gt;if (es != NULL) {&lt;BR /&gt;es-&amp;gt;state = ES_ACCEPTED;&lt;BR /&gt;es-&amp;gt;pcb = newpcb;&lt;BR /&gt;es-&amp;gt;retries = 0;&lt;BR /&gt;es-&amp;gt;p = NULL;&lt;BR /&gt;/* pass newly allocated es to our callbacks */&lt;BR /&gt;tcp_arg(newpcb, es);&lt;BR /&gt;tcp_recv(newpcb, tcpecho_raw_recv);&lt;BR /&gt;tcp_err(newpcb, tcpecho_raw_error);&lt;BR /&gt;tcp_poll(newpcb, tcpecho_raw_poll, 0);&lt;BR /&gt;tcp_sent(newpcb, tcpecho_raw_sent);&lt;BR /&gt;ret_err = ERR_OK;&lt;BR /&gt;} else {&lt;BR /&gt;ret_err = ERR_MEM;&lt;BR /&gt;}&lt;BR /&gt;return ret_err;&lt;BR /&gt;}&lt;/P&gt;&lt;P&gt;void tcp_recv_callback(void *arg, struct tcp_pcb *pcb, struct pbuf *p)&lt;BR /&gt;{&lt;BR /&gt;// process received data here&lt;BR /&gt;// ...&lt;BR /&gt;PRINTF("tcp_recv_callback done .\n");&lt;BR /&gt;// indicate that the data was processed successfully&lt;BR /&gt;tcp_recved(pcb, p-&amp;gt;tot_len);&lt;/P&gt;&lt;P&gt;// free the packet buffer&lt;BR /&gt;pbuf_free(p);&lt;BR /&gt;}&lt;/P&gt;&lt;P&gt;void tcp_sent_callback(void *arg, struct tcp_pcb *pcb, u16_t len)&lt;BR /&gt;{&lt;BR /&gt;// the data has been successfully sent&lt;BR /&gt;// ...&lt;BR /&gt;PRINTF("tcp_sent_callback done .\n");&lt;BR /&gt;// free any memory used to store the sent data&lt;BR /&gt;// ...&lt;BR /&gt;}&lt;BR /&gt;void close_conn(void)&lt;BR /&gt;{&lt;BR /&gt;closing = true;&lt;BR /&gt;tcp_close(tcpecho_raw_pcb);&lt;BR /&gt;}&lt;/P&gt;&lt;P&gt;// Define a callback function to handle the connected event&lt;BR /&gt;void connected_callback(void *arg, struct tcp_pcb *tpcb, err_t err) {&lt;BR /&gt;if (err == ERR_OK) {&lt;/P&gt;&lt;P&gt;PRINTF("Connecting to server............................\n");&lt;BR /&gt;PRINTF("\n");&lt;BR /&gt;// Connection was successful&lt;BR /&gt;PRINTF("Connected to remote endpoint!\n");&lt;BR /&gt;PRINTF("\r\n");&lt;BR /&gt;PRINTF("***** SERVER IP -&amp;gt;&amp;gt; 192.168.0.150 ********\n");&lt;/P&gt;&lt;P&gt;char str[]="HELLO, V3 NOVUS\n";&lt;BR /&gt;int len=strlen(str);&lt;/P&gt;&lt;P&gt;// Send data over the connection&lt;BR /&gt;tcp_write(tpcb, "HELLO, V3 NOVUS\n", len, TCP_WRITE_FLAG_COPY); //&lt;BR /&gt;flag=1;&lt;BR /&gt;} else {&lt;BR /&gt;// Connection failed&lt;BR /&gt;PRINTF("Failed to connect to remote endpoint.\n");&lt;BR /&gt;}&lt;BR /&gt;}&lt;/P&gt;&lt;P&gt;#if 0&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;void vSendTask( void *pvParameters )&lt;BR /&gt;{&lt;BR /&gt;tcp_sent(tcpecho_raw_pcb,tcpecho_raw_sent);&lt;/P&gt;&lt;P&gt;}&lt;/P&gt;&lt;P&gt;void vReceiveTask( void *pvParameters )&lt;BR /&gt;{&lt;BR /&gt;tcp_recv(tcpecho_raw_pcb, tcpecho_raw_recv);&lt;/P&gt;&lt;P&gt;}&lt;/P&gt;&lt;P&gt;#endif&lt;BR /&gt;void&lt;BR /&gt;tcpecho_raw_init(void)&lt;BR /&gt;{&lt;BR /&gt;tcpecho_raw_pcb = tcp_new_ip_type(IPADDR_TYPE_ANY);&lt;BR /&gt;if (tcpecho_raw_pcb != NULL) {&lt;BR /&gt;err_t err;&lt;BR /&gt;PRINTF("NEW_SOCKET_CREATED.\n");&lt;BR /&gt;err = tcp_bind(tcpecho_raw_pcb, IP_ANY_TYPE, 9000);&lt;BR /&gt;PRINTF("tcp_bind pass .\n");&lt;BR /&gt;if (err == ERR_OK) {&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;// tcpecho_raw_pcb = tcp_listen(tcpecho_raw_pcb);&lt;BR /&gt;// tcp_accept(tcpecho_raw_pcb, tcpecho_raw_accept);&lt;BR /&gt;// PRINTF("tcp_accept pass .\n");&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;// PRINTF("Waiting for incoming connection...\n");&lt;BR /&gt;// for(int i=0;i&amp;lt;1000;i++);// wait for 1 second&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;ip_addr_t ipaddr;&lt;BR /&gt;IP4_ADDR(&amp;amp;ipaddr, 192, 168, 0, 150);&lt;BR /&gt;u16_t port = 9000;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;err_t con = tcp_connect(tcpecho_raw_pcb,&amp;amp;ipaddr,port ,connected_callback);&lt;/P&gt;&lt;P&gt;if(con == ERR_OK) {&lt;/P&gt;&lt;P&gt;PRINTF("tcp_connect pass .\n");&lt;BR /&gt;}&lt;/P&gt;&lt;P&gt;#if 0&lt;BR /&gt;while(1)&lt;BR /&gt;{&lt;BR /&gt;USART_ReadBlocking(ENC_USART, Udatabuf,sizeof(Udatabuf));&lt;BR /&gt;USART_WriteBlocking(ENC_USART, Udatabuf, sizeof(Udatabuf));&lt;BR /&gt;// Send data over the connection&lt;BR /&gt;tcp_write(tcpecho_raw_pcb, Udatabuf, sizeof(Udatabuf), TCP_WRITE_FLAG_COPY);&lt;BR /&gt;}&lt;BR /&gt;#endif&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;tcp_sent(tcpecho_raw_pcb,tcpecho_raw_sent);&lt;/P&gt;&lt;P&gt;PRINTF("tcp_recv done .\n");&lt;BR /&gt;tcp_recv(tcpecho_raw_pcb, tcpecho_raw_recv);&lt;/P&gt;&lt;P&gt;for(int i=0;i&amp;lt;50000;i++);// increase the delay and check once&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;// err_t val = tcp_close(tcpecho_raw_pcb);&lt;BR /&gt;// PRINTF("tcp_close.%d\n",val);&lt;BR /&gt;tcp_err(tpcb, error_callback);&lt;/P&gt;&lt;P&gt;} else {&lt;BR /&gt;/* abort? output diagnostic? */&lt;BR /&gt;}&lt;BR /&gt;} else {&lt;BR /&gt;/* abort? output diagnostic? */&lt;BR /&gt;}&lt;BR /&gt;}&lt;/P&gt;&lt;P&gt;#endif /* LWIP_TCP */&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;main&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;/*&lt;BR /&gt;* Copyright (c) 2016, Freescale Semiconductor, Inc.&lt;BR /&gt;* Copyright 2016-2017 NXP&lt;BR /&gt;* All rights reserved.&lt;BR /&gt;*&lt;BR /&gt;*&lt;BR /&gt;* SPDX-License-Identifier: BSD-3-Clause&lt;BR /&gt;*/&lt;/P&gt;&lt;P&gt;/*******************************************************************************&lt;BR /&gt;* Includes&lt;BR /&gt;******************************************************************************/&lt;BR /&gt;#include "lwip/opt.h"&lt;/P&gt;&lt;P&gt;#if LWIP_TCP&lt;/P&gt;&lt;P&gt;#include "tcpecho_raw.h"&lt;BR /&gt;#include "lwip/timeouts.h"&lt;BR /&gt;#include "lwip/init.h"&lt;BR /&gt;#include "netif/ethernet.h"&lt;BR /&gt;#include "ethernetif.h"&lt;BR /&gt;#include "fsl_debug_console.h"&lt;BR /&gt;#include "board.h"&lt;/P&gt;&lt;P&gt;#include "pin_mux.h"&lt;BR /&gt;#include &amp;lt;stdbool.h&amp;gt;&lt;BR /&gt;/*******************************************************************************&lt;BR /&gt;* Definitions&lt;BR /&gt;******************************************************************************/&lt;/P&gt;&lt;P&gt;/* IP address configuration. */&lt;BR /&gt;#define configIP_ADDR0 192&lt;BR /&gt;#define configIP_ADDR1 168&lt;BR /&gt;#define configIP_ADDR2 0&lt;BR /&gt;#define configIP_ADDR3 102&lt;/P&gt;&lt;P&gt;/* Netmask configuration. */&lt;BR /&gt;#define configNET_MASK0 255&lt;BR /&gt;#define configNET_MASK1 255&lt;BR /&gt;#define configNET_MASK2 255&lt;BR /&gt;#define configNET_MASK3 0&lt;/P&gt;&lt;P&gt;/* Gateway address configuration. */&lt;BR /&gt;#define configGW_ADDR0 192&lt;BR /&gt;#define configGW_ADDR1 168&lt;BR /&gt;#define configGW_ADDR2 0&lt;BR /&gt;#define configGW_ADDR3 100&lt;/P&gt;&lt;P&gt;/* MAC address configuration. */&lt;BR /&gt;#define configMAC_ADDR {0x02, 0x12, 0x13, 0x10, 0x15, 0x11}&lt;/P&gt;&lt;P&gt;/* Address of PHY interface. */&lt;BR /&gt;#define EXAMPLE_PHY_ADDRESS BOARD_ENET0_PHY_ADDRESS&lt;/P&gt;&lt;P&gt;/* System clock name. */&lt;BR /&gt;#define EXAMPLE_CLOCK_NAME kCLOCK_CoreSysClk&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;/*******************************************************************************&lt;BR /&gt;* Prototypes&lt;BR /&gt;******************************************************************************/&lt;/P&gt;&lt;P&gt;/*******************************************************************************&lt;BR /&gt;* Variables&lt;BR /&gt;******************************************************************************/&lt;/P&gt;&lt;P&gt;/*******************************************************************************&lt;BR /&gt;* Code&lt;BR /&gt;******************************************************************************/&lt;/P&gt;&lt;P&gt;/*!&lt;BR /&gt;* @brief Interrupt service for SysTick timer.&lt;BR /&gt;*/&lt;BR /&gt;void SysTick_Handler(void)&lt;BR /&gt;{&lt;BR /&gt;time_isr();&lt;BR /&gt;}&lt;/P&gt;&lt;P&gt;/*!&lt;BR /&gt;* @brief Main function.&lt;BR /&gt;*/&lt;BR /&gt;int main(void)&lt;BR /&gt;{&lt;BR /&gt;struct netif fsl_netif0;&lt;BR /&gt;ip4_addr_t fsl_netif0_ipaddr, fsl_netif0_netmask, fsl_netif0_gw;&lt;BR /&gt;ethernetif_config_t fsl_enet_config0 = {&lt;BR /&gt;.phyAddress = EXAMPLE_PHY_ADDRESS,&lt;BR /&gt;.clockName = EXAMPLE_CLOCK_NAME,&lt;BR /&gt;.macAddress = configMAC_ADDR,&lt;BR /&gt;};&lt;/P&gt;&lt;P&gt;CLOCK_EnableClock(kCLOCK_InputMux);&lt;BR /&gt;&lt;BR /&gt;/* attach 12 MHz clock to FLEXCOMM0 (debug console) */&lt;BR /&gt;CLOCK_AttachClk(BOARD_DEBUG_UART_CLK_ATTACH);&lt;/P&gt;&lt;P&gt;BOARD_InitPins();&lt;BR /&gt;BOARD_BootClockFROHF96M();&lt;BR /&gt;BOARD_InitDebugConsole();&lt;/P&gt;&lt;P&gt;time_init();&lt;/P&gt;&lt;P&gt;IP4_ADDR(&amp;amp;fsl_netif0_ipaddr, configIP_ADDR0, configIP_ADDR1, configIP_ADDR2, configIP_ADDR3);&lt;BR /&gt;IP4_ADDR(&amp;amp;fsl_netif0_netmask, configNET_MASK0, configNET_MASK1, configNET_MASK2, configNET_MASK3);&lt;BR /&gt;IP4_ADDR(&amp;amp;fsl_netif0_gw, configGW_ADDR0, configGW_ADDR1, configGW_ADDR2, configGW_ADDR3);&lt;/P&gt;&lt;P&gt;lwip_init();&lt;/P&gt;&lt;P&gt;netif_add(&amp;amp;fsl_netif0, &amp;amp;fsl_netif0_ipaddr, &amp;amp;fsl_netif0_netmask, &amp;amp;fsl_netif0_gw,&lt;BR /&gt;&amp;amp;fsl_enet_config0, ethernetif0_init, ethernet_input);&lt;BR /&gt;netif_set_default(&amp;amp;fsl_netif0);&lt;BR /&gt;netif_set_up(&amp;amp;fsl_netif0);&lt;/P&gt;&lt;P&gt;tcpecho_raw_init();&lt;/P&gt;&lt;P&gt;PRINTF("\r\n************************************************\r\n");&lt;BR /&gt;PRINTF(" CLIENT IP\r\n");&lt;BR /&gt;PRINTF("************************************************\r\n");&lt;BR /&gt;PRINTF(" IPv4 Address : %u.%u.%u.%u\r\n", ((u8_t *)&amp;amp;fsl_netif0_ipaddr)[0], ((u8_t *)&amp;amp;fsl_netif0_ipaddr)[1],&lt;BR /&gt;((u8_t *)&amp;amp;fsl_netif0_ipaddr)[2], ((u8_t *)&amp;amp;fsl_netif0_ipaddr)[3]);&lt;BR /&gt;PRINTF(" IPv4 Subnet mask : %u.%u.%u.%u\r\n", ((u8_t *)&amp;amp;fsl_netif0_netmask)[0], ((u8_t *)&amp;amp;fsl_netif0_netmask)[1],&lt;BR /&gt;((u8_t *)&amp;amp;fsl_netif0_netmask)[2], ((u8_t *)&amp;amp;fsl_netif0_netmask)[3]);&lt;BR /&gt;PRINTF(" IPv4 Gateway : %u.%u.%u.%u\r\n", ((u8_t *)&amp;amp;fsl_netif0_gw)[0], ((u8_t *)&amp;amp;fsl_netif0_gw)[1],&lt;BR /&gt;((u8_t *)&amp;amp;fsl_netif0_gw)[2], ((u8_t *)&amp;amp;fsl_netif0_gw)[3]);&lt;BR /&gt;PRINTF("************************************************\r\n");&lt;/P&gt;&lt;P&gt;while (1)&lt;BR /&gt;{&lt;BR /&gt;/* Poll the driver, get any outstanding frames */&lt;BR /&gt;ethernetif_input(&amp;amp;fsl_netif0);&lt;/P&gt;&lt;P&gt;sys_check_timeouts(); /* Handle all system timeouts for all core protocols */&lt;BR /&gt;}&lt;BR /&gt;}&lt;BR /&gt;#endif&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;please help to solve these&lt;/P&gt;</description>
      <pubDate>Sat, 18 Mar 2023 17:08:14 GMT</pubDate>
      <guid>https://community.nxp.com/t5/LPC-Microcontrollers/Socket-creation/m-p/1617967#M51947</guid>
      <dc:creator>sachinn434</dc:creator>
      <dc:date>2023-03-18T17:08:14Z</dc:date>
    </item>
  </channel>
</rss>

