/*@@var:*/ variables { const long INVALID_SOCKET = ~0; const long WSA_IO_PENDING = 997; const long WSAEWOULDBLOCK = 10035; const dword INVALID_IP = 0xffffffff; dword gIpAddress = INVALID_IP; char gIpLastErrStr[1024] = ""; char gIpAddressStr[32] = ""; int gIpLastErr = 0; dword gUdpPort = 0; long gUdpSocket = INVALID_SOCKET; char gUdpRxBuffer[4096]; dword gTcpPort = 0; long gTcpSocket = INVALID_SOCKET; long gTcpDataSocket = INVALID_SOCKET; char gTcpRxBuffer[8192]; // status int gStatus = 0; const int gkSTATUS_UNINITIALISED = 0; const int gkSTATUS_INITIALISED = 1; } /*@@end*/ /*@@caplFunc:UdpReceive(dword):*///function long UdpRecv( dword socket) { int result = 0; result = UdpReceiveFrom( socket, gUdpRxBuffer, elcount( gUdpRxBuffer)); if ( 0 != result) { gIpLastErr = IpGetLastSocketError( socket); if ( WSA_IO_PENDING != gIpLastErr) { IpGetLastSocketErrorAsString( socket, gIpLastErrStr, elcount( gIpLastErrStr)); writelineex( 0, 2, "UdpReceive error (%d): %s", gIpLastErr, gIpLastErrStr); } } return result; } /*@@end*/ /*@@caplFunc::*///function long TcpRecv( dword socket) { int result = 0; result = TcpReceive( socket, gTcpRxBuffer, elcount( gTcpRxBuffer)); if ( 0 != result) { gIpLastErr = IpGetLastSocketError( socket); if ( WSA_IO_PENDING != gIpLastErr) { IpGetLastSocketErrorAsString( socket, gIpLastErrStr, elcount( gIpLastErrStr)); writelineex( 0, 2, "TcpReceive error (%d): %s", gIpLastErr, gIpLastErrStr); } } return result; } /*@@end*/