Author Topic: TCP client send  (Read 6336 times)

Offline jpa

  • Newbie
  • *
  • Posts: 9
    • View Profile
TCP client send
« on: April 19, 2011, 10:55:57 PM »
(Should I be adding to the pinned TCP topic?)

I'm trying to create a TCP client and send data.  I can connect, and the first packet gets through, but then the second packet is tagged as "TCP Out-of-Order" by Wireshark and is apparently not received by the server.  The basic intention is to make what is essentially a serial-to-ethernet converter.  The serial receive routines gather together a whole message and call "as_send" below.  It is NOT called from the callback function since it's not being sent as the response to a server message.  Is that the key?  The callback function is the fnTestListener from your TCP thread except the TCP_EVENT_DATA case just prints out the fact that data has been received (so then it falls through and returns APP_ACCEPT).

I've attached the Wireshark log... uTasker client is 192.168.1.10 trying to send a 32 byte packet to 192.168.1.4.

JPA

Code: [Select]
typedef struct stTCP_MESSAGE
{
    TCP_HEADER     tTCP_Header;     // reserve header space
    PACKET_TYPE   packet;
} TCP_MESSAGE;

//=============================================================================
int as_send(int as_index, const void *msg, size_t len, int flags)
{
unsigned int i;
TCP_MESSAGE test_message;

uMemcpy(&test_message.packet, msg, sizeof(PACKET_TYPE));
if (fnSendTCP(test_client_socket, (unsigned char *) &test_message.tTCP_Header, sizeof(PACKET_TYPE), TCP_FLAG_PUSH) > 0) {
fnDebugMsg("sent ok?\r\n");
        return 0;
}
else
return 0;
}

Offline jpa

  • Newbie
  • *
  • Posts: 9
    • View Profile
Re: TCP client send
« Reply #1 on: April 20, 2011, 03:54:42 PM »
Never mind.  I re-read the later posts (in the TCP thread) about buffered TCP, and seem to be making progress.

JPA