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

Just starting out? Need help? Post your questions and find answers here.
oliv
User
User
Posts: 42
Joined: Sun Aug 24, 2003 10:11 am
Location: France

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

Post 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
Tranquil
Addict
Addict
Posts: 952
Joined: Mon Apr 28, 2003 2:22 pm
Location: Europe

Post 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.
Tranquil
oliv
User
User
Posts: 42
Joined: Sun Aug 24, 2003 10:11 am
Location: France

Post 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:
Tranquil
Addict
Addict
Posts: 952
Joined: Mon Apr 28, 2003 2:22 pm
Location: Europe

Post 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.
Tranquil
oliv
User
User
Posts: 42
Joined: Sun Aug 24, 2003 10:11 am
Location: France

Post 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...
Post Reply