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 ?
Oh, yes!
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
Hi All ,
I am sorry to bring the difficulty for you to read my source code because I simply use copy & paste without re-align it.
I should improve it next time. Thank for all your kindly help !
Consider using BSD-socket interface. Then the usage of sockets is the same as on PC.
Hi Christian ,
May thanks for your help !
After adapt your code and through wireshark monitor, I have fiexd the problem. I have to add /r/n then the PC can receive the sending string.
No problem