Restored from previous forum. Originally posted by tranquil.
If you send files to the TCP/IP Buffer (large ones) and the TCP/IP buffer is full couse your internet or lan connection could not process the datas as fast as your application sends it, you have to resend the datas some msecs later.
SendNetworkData() returns the amount of bytes send by TCP/IP. If there is a problem during that there is a #SOCKET_ERROR reported.
Tha API command wsagetlasterror_() reports the error detail which can be one of the following:
If wsaerror=#WSANOTINITIALISED:err$="Wsa not initialized":EndIf
If wsaerror=#WSAENETDOWN :err$="The Windows Sockets implementation has detected that the network subsystem has failed.":EndIf
If wsaerror=#WSAENOTCONN :err$="Socket not connected.":EndIf
If wsaerror=#WSAEINTR :err$="The (blocking) call was canceled using WSACancelBlocking":EndIf
If wsaerror=#WSAEINPROGRESS :err$="A blocking Windows Sockets operation is in progress.":EndIf
If wsaerror=#WSAENOTSOCK :err$="The descriptor is not a socket.":EndIf
If wsaerror=#WSAEOPNOTSUPP :err$="MSG_OOB was specified, but the socket is not of type SOCK_STREAM.":EndIf
If wsaerror=#WSAESHUTDOWN :err$="The socket has been shut down; it is not possible to recv on a socket after shutdown has been invoked with how set to 0 or 2.":EndIf
If wsaerror=#WSAEMSGSIZE :err$="The datagram was too large to fit into the specified buffer and was truncated.":EndIf
If wsaerror=#WSAEINVAL :err$="The socket has not been bound with bind.":EndIf
If wsaerror=#WSAECONNABORTED :err$="The virtual circuit was aborted due to timeout or other failure.":EndIf
If wsaerror=#WSAECONNRESET :err$="The virtual circuit was reset by the remote side.":EndIf
If wsaerror=#WSAEWOULDBLOCK :err$="The socket is marked as nonblocking":EndIf
If wsaerror=#WSAEWOULDBLOCK:send=0:sended=0:Delay(250):EndIf
#WSAEWOULDBLOCK is the most importend. This is reported when the TCP/IP Buffer is full or can not process your datas yet. Only wait a short time and try again.
Same thingie on ReceiveNetworkData. Its STRONGLY recommanded that you check, how many bytes are receives with ReceiveNetworkdata().
ReceiveNetworkdata() Returns the number of bytes received. This can be another amount of bytes then the SendNetworkData().
Eg.: You call SendnetworkData() with sending 20 Bytes.
The first call of receivenetworkdata() receives the first 15 Bytes (couse the rest of 5 bytes cames with another TCP/IP Packet and tackes a bit longer) you have to call receivenetworkdata() again and again till your datapacket is complete.
On Serversides you need a Buffer for every connected Socket for completing your Datapackets.
Hope that helpes a bit.
Tranquilizer/ Secretly!
http://www.secretly.de
Registred PureBasic User
System: Windows 2000 Server, 512 MB Ram, GeForce4200 TI 128 MB DDR, Hercules Theater 6.1 DTS Sound
System 2: Mobile Pentium 4 2.4GHz 512 MB DDR GeForce4 420-32, Windows XP Home