<?xml version="1.0" encoding="UTF-8" ?>
<?xml-stylesheet type="text/xsl" href="https://community.arm.com/utility/feedstylesheets/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/"><channel><title>LPC2388 making as Active socket</title><link>https://community.arm.com/developer/tools-software/tools/f/keil-forum/24255/lpc2388-making-as-active-socket</link><description> 
I have a MCB2300 board from Keil. I am trying to make my ARM as
active socket. since so i was looking into sample program which given
to me. From the document 

 
This program is a LEDSwitch Server example. It shows you how to control
embedded device</description><dc:language>en-US</dc:language><generator>Telligent Community 10</generator><item><title>RE: LPC2388 making as Active socket</title><link>https://community.arm.com/thread/89804?ContentTypeID=1</link><pubDate>Sat, 06 Jun 2009 04:00:28 GMT</pubDate><guid isPermaLink="false">dd9e70c8-6d3c-4c71-b136-2456382a7b5c:65bbf10b-c9ca-4a3d-8817-454136689cdf</guid><dc:creator>dhanaraj shanmugam</dc:creator><description>&lt;p&gt;&lt;p&gt;
As you said i made my board as client and 3 PC&amp;#39;s as a listener. So
i was successful of making them waiting for my data. I was able to
display my data on those three PC&amp;#39;s Hyperterminal on &lt;b&gt;waiting for a
call&lt;/b&gt;. But the message i was not able to display as i desired.&lt;br /&gt;
And i was making &lt;b&gt;port2.0 to port2.4&lt;/b&gt; Pins high and Low as per
the connection status. There also i found some problem that making
low and high is not what i desired.&lt;/p&gt;

&lt;p&gt;
Here&amp;#39;s my code. Please check it and tell me where i have done the
mistakes. Only one line i was getting on all of the terminal
continuously. That line is &amp;quot;First Remote Connected&amp;quot;.&lt;/p&gt;

&lt;pre&gt;
#include &amp;lt;stdio.h&amp;gt;
#include &amp;lt;LPC23xx.H&amp;gt;
#include &amp;lt;RTL.h&amp;gt;
#include &amp;lt;string.h&amp;gt;
#include &amp;lt;Net_Config.h&amp;gt;

#define MCLK 48000000                         /* Master Clock 48 MHz         */
#define TCLK       10                         /* Timer Clock rate 10/s       */
#define TCNT (MCLK/TCLK/4)                    /* Timer Counts                */

 U8 remote_ip1[4][3] = {172, 16, 21, 233,
                                           172, 16, 21, 36,
                                           172, 16, 21, 13      };

 U8 tcp_soc;
 static U8 soc_state;
 BOOL wait_ack;
 BOOL tick;

void init()
{
   /* Timer 1 as interval timer, reload to 100ms. */
   T1TCR = 1;
   T1MCR = 3;
   T1MR0 = TCNT - 1;

}

/*Calling 2nd PC&amp;#39;s IP to make a accept the connection*/

void soc_callback(){
  U8 data[30];
  U8 remote_ip[4]={172, 16, 21, 36};
  U8 *sendbuf;

   switch(tcp_get_state(tcp_soc))
  {
        case TCP_STATE_FREE:
        case TCP_STATE_CLOSED :
                FIO2SET=0x08;
                soc_state=3;
                tcp_connect(tcp_soc, remote_ip, 1003, 0);
                if(tcp_check_send(tcp_soc)){
                        strcpy((char *)data, &amp;quot; Second remote Connected&amp;quot;); //This line want to be displayed whenever made a connection
                        sendbuf = tcp_get_buf (sizeof(data));
                        memcpy (sendbuf, data, sizeof(data));
                        tcp_send(tcp_soc, sendbuf, 30 );

                        return;
                        }
                break;

        case TCP_STATE_CONNECT:

                FIO2CLR=0x08;
                soc_state=4;
                if(tcp_check_send(tcp_soc)){
                        strcpy((char *)data, &amp;quot; Second remote Connected&amp;quot;);
                        sendbuf = tcp_get_buf (sizeof(data));
                        memcpy (sendbuf, data, sizeof(data));
                        tcp_send(tcp_soc, sendbuf, 30 );

                        return;
                }
                break;

        }
}

/*Calling 3rd PC&amp;#39;s IP to make a accept the connection */
void soc_callback1(){
  U8 data[30];
  U8 remote_ip[4]={172, 16, 21, 13};  //IP of the 3rd PC
  U8 *sendbuf;

   switch(tcp_get_state(tcp_soc))
  {
        case TCP_STATE_FREE:
        case TCP_STATE_CLOSED :
                FIO2SET=0x10;
                soc_state=5;
                tcp_connect(tcp_soc, remote_ip, 1004, 0); //Port number of PC
                if(tcp_check_send(tcp_soc)){
                        strcpy((char *)data, &amp;quot; Third remote Connected&amp;quot;);
                        sendbuf = tcp_get_buf (sizeof(data));
                        memcpy (sendbuf, data, sizeof(data));
                        tcp_send(tcp_soc, sendbuf, 20 );

                        return;
                }
                break;

        case TCP_STATE_CONNECT:

                FIO2CLR=0x10;
                soc_state=6;
                if(tcp_check_send(tcp_soc)){
                        strcpy((char *)data, &amp;quot; Third remote Connected&amp;quot;);
                        sendbuf = tcp_get_buf (sizeof(data));
                        memcpy (sendbuf, data, sizeof(data));
                        tcp_send(tcp_soc, sendbuf, 20 );

                        return;
                }
                break;

        }
}

void send_data()
{
  U8 data[30];
  U8 remote_ip[4] = {172, 16, 21, 233};  // IP of my system
  U8 *sendbuf;

  switch(tcp_get_state(tcp_soc))
  {
        case TCP_STATE_FREE:
        case TCP_STATE_CLOSED :
                FIO2SET=0x04;
                soc_state=1;
                tcp_connect(tcp_soc, remote_ip, 1002, 0); //Port num
                break;

        case TCP_STATE_CONNECT:

                FIO2CLR=0x04;
                soc_state=2;
                if(tcp_check_send(tcp_soc)){
                        strcpy((char *)data, &amp;quot;First Remote Connected&amp;quot;);//This is the only line i am getting.
                        sendbuf = tcp_get_buf (sizeof(data));
                        memcpy (sendbuf, data, sizeof(data));
                        tcp_send(tcp_soc, sendbuf, 22 );

                        return;
                }
                break;

        }
}
/*--------------------------- timer_poll ------------------------------------*/

static void timer_poll () {
   /* System tick timer running in poll mode */

   if (T1IR &amp;amp; 1) {
      T1IR = 1;
      /* Timer tick every 100 ms */
      timer_tick ();
      tick = __TRUE;
   }
}


U16 tcp_callback(U8 soc, U8 event, U8 *ptr, U16 par)
{
        switch(event)
        {
                case TCP_EVT_CONNECT:
//                              soc_state = 2;
                                FIO2SET=0x02;
                                break;

                case TCP_EVT_ABORT:
//                              soc_state = 0;
                                FIO2CLR=0x01;
                                break;

                case TCP_EVT_ACK:
//                              wait_ack =__FALSE;
                                FIO2SET=0x01;
//                              FIO2CLR=0x02;
                                break;

                case TCP_EVT_CLOSE:
//                              Connection Closed
                                FIO2CLR=0x02;
                                break;
        }
        return(0);
}


int main()
{
 PINSEL10 = 0;
 FIO2DIR = 0x000000ff;
 soc_state=0;

 init();
 init_TcpNet ();
 tcp_soc = tcp_get_socket(TCP_TYPE_CLIENT, 0, 30, tcp_callback);
// soc_state = 0;

 while(1)
 {
  timer_poll ();
  main_TcpNet ();

//  send_data();
  /*Checking status of all the connection and sending the messages to the one who&amp;#39;s waiting for a call*/
  if(soc_state ==2)
  {
  soc_callback();
  }
  else if(soc_state ==4)
  {
  soc_callback1();
  }
  else
  {
  send_data();
  }

 }
}

&lt;/pre&gt;
&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: LPC2388 making as Active socket</title><link>https://community.arm.com/thread/56221?ContentTypeID=1</link><pubDate>Fri, 05 Jun 2009 05:49:43 GMT</pubDate><guid isPermaLink="false">dd9e70c8-6d3c-4c71-b136-2456382a7b5c:e4b34a09-fc48-4be1-8cd7-26941f800a30</guid><dc:creator>ImPer Westermark</dc:creator><description>&lt;p&gt;&lt;p&gt;
I have to guess that you with &amp;quot;active socket&amp;quot; intended the board
to be a client.&lt;/p&gt;

&lt;p&gt;
There are no active or passive sockets even if you can have
protocols such as &amp;quot;passive ftp&amp;quot; that makes use of terms such as
active or passive.&lt;/p&gt;

&lt;p&gt;
The &lt;b&gt;client&lt;/b&gt; makes the connection.&lt;br /&gt;
The &lt;b&gt;server&lt;/b&gt; accepts the connection.&lt;/p&gt;
&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>