Like Ali, I seem to also have a sockets problem. I'm using a Symbol 1740
unit, CW 6
all the latest stuff, etc., etc.
I can make the TCP connection just fine, the data is written that I want
to send ok, but
it seems to be buffered somewhere in the socket (or elsewhere??) because
it doesn't
actually make it through to the other end. It's only when I explicitly
'close' the socket
that the data seems to be flushed to the other side.
I'll admit I'm a novice when it comes to socket programming, but why
doesn't it actually
make it to the receiving end until the close? Is there a way to force a
flush of the buffer?
I've copied, essentially, the calls used in the "Echo" project in the
Symbol examples. That
project works just fantastic when I test it out (of course, I'm not
looping forever).
Any ideas? Code snippet below:
//open port
//if ((FD = tcp_open(pHost, pServiceName ,PortNum)) < 0)
if ((FD = NetUTCPOpen(pHost, pServiceName, PortNum)) < 0)
{
Disconnect();
FrmCustomAlert(ConnectAlert, "Failed to open TCP port
specified.", "", "");
return false;
}
TimeOut = SysSetAutoOffTime(0); //make sure device stays on
//send data over open port
RefreshNetwork(true);
SentBytes = NetUWriteN(FD, (BytePtr)sendbuffer, Reqlen);
if (SentBytes != Reqlen)
{
Disconnect();
FrmCustomAlert(ConnectAlert, "Bytes sent did not match!",
"", "");
return false;
}
//get return data
RefreshNetwork(true);
RecvBytes = ReadN(FD, (BytePtr)recvbuffer, rcvbuflen);
while ((RecvBytes != 0) && (RecvBytes > 0))
{
TotBytes += RecvBytes;
StrCat(XMLRcvd, recvbuffer);
//do something if more data coming but buffer is now
full??
recvbuffer = 0;
RecvBytes = ReadN(FD, (BytePtr)recvbuffer, rcvbuflen);
}
if (RecvBytes < 0) //some error occurred
{
Disconnect();
FrmCustomAlert(ConnectAlert, "Error in receiving return
data!", "", "");
return false;
}
//make sure to close everything and clean up
Disconnect();
TIA - Robert
--
For information on using the Palm Developer Forums, or to unsubscribe, please see
http://www.palmos.com/dev/tech/support/forums/