Page 1 of 1

SendNetworkData() problems, return "-1" sometimes,

Posted: Sun Dec 16, 2007 12:20 pm
by oliv
Hi,
I have some troubles with the SendNetworkData(). My program send data with success 8/9 times, then the SendNetworkData() return -1 and it can't send data again. I there a way to know how it return -1 ?

Thanks, and sorry for my bad English

Posted: Sun Dec 16, 2007 2:43 pm
by Tranquil
This can be normal. -1 means that a socket_error occures. Maybe nothing special and not a problem.
You can get more information using the WSAGetLastError_() Windows API.

The most reason for this is, that you try to send datas faster then the connection or the recipient can handle this. In this case WSAGetLastError() will return that the socket is in blocked state. You only have to wait some ms (I using a delay of 250 which is a value I found on MSDN for this issue) and try sending your datapackage again.

Posted: Mon Dec 17, 2007 12:01 am
by oliv
Thanks,
I see that include Delay() avoid "-1" return code, but I already tried to use WSGA_GetLastError() and it returns 0 :oops:

Posted: Mon Dec 17, 2007 6:31 am
by Tranquil
WSAGetLastError returns 0? Hm thats mysterious couse SendNetworkData should only be a wrapper to the windows API send_ command. Try replaceing SendNetworkData with the send_ command, its nearly the same syntax expect that send_ requires a socket handle instead of a pb internaly handled connectionID. To convert the ConnectionID to a socket use:

socket = ConnectionID(youridhere.l)

You can also post a snipped of your code so that we can take a look on it.

Posted: Mon Dec 17, 2007 9:29 am
by oliv
I searched about it and found a page on MSDN which explains that the function WSGAGetLastError() can returns 0 when it is uses for network.

I have post me code here, the problem with "-1" return code is solved but there is mysterious bugs...