This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

How to send data in TCP_Server

I am using MCB1700 as TCP server and I can received data from PC client.
But I can not send data back to the PC client while the TCP is still connected. Is there any one who has experience to do that ?

In the /TCPnet/LEDSwitch example, I managed to receive data from PC client but I don't know how to send the response/data back to the PC client? which function can be used ? Is there any one who has example ?

Parents
  • Hi:

    1: you don't need the state machine inside the send_data function.

    2: are you sure that you have stablished a connection to socket? check wireshark for traffic and make sure that you have the handshake sequence.

    3: the function below should work:

    void send_data (U8 p2val)
    {

    U8 *ucSendbuf; U32 unIndex;

    if (tcp_check_send (tcp_soc))

    { ucSendbuf = tcp_get_buf (p2val);

    // copy bytes to send buffer.

    for (unIndex = 0; unIndex < p2val ; unIndex++)

    {

    ucSendbuf[unIndex] = 'A'; }

    tcp_send (tcp_soc, ucSendbuf, p2val );

    }

    } // end function

Reply
  • Hi:

    1: you don't need the state machine inside the send_data function.

    2: are you sure that you have stablished a connection to socket? check wireshark for traffic and make sure that you have the handshake sequence.

    3: the function below should work:

    void send_data (U8 p2val)
    {

    U8 *ucSendbuf; U32 unIndex;

    if (tcp_check_send (tcp_soc))

    { ucSendbuf = tcp_get_buf (p2val);

    // copy bytes to send buffer.

    for (unIndex = 0; unIndex < p2val ; unIndex++)

    {

    ucSendbuf[unIndex] = 'A'; }

    tcp_send (tcp_soc, ucSendbuf, p2val );

    }

    } // end function

Children