[Gambas-user] Old problem.
danielcampos at ...282...
danielcampos at ...282...
Wed Nov 19 09:34:19 CET 2003
>>
>>Do the following before binding the socket:
>>
>> int auth = 1;
>> setsockopt(sock_fd, SOL_SOCKET, SO_REUSEADDR, &auth, sizeof(int));
>>
>>I don't know if it works, I read this in a book, and I don't know if it works
>>on other systems than Linux.
>>
Thanks, I didn't know that option at all, but I'll add it as seems to work fine. I've
searched more about it at internet, and some people even thinks this is a
bug from Linux sockets implementation. This option seems to be not standard,
some UNIXes support it, some other support it but doesn't need it to "rebind" the
socket, and some other does not support it... I've found that, for example :
"---------------------------
Now back to the bug in Linux. When you open a socket, you must also call
the setsockopt() function with the following segment of code:
#ifdef LINUX
opt = 1; len = sizeof(opt);
setsockopt(sockfd,SOL_SOCKET,SO_REUSEADDR,&opt,&len);
#endif
The #ifdef and #endif statements are necessary only if you want to port the code
over to systems other than Linux. Some UNIX systems might not support or
require the SO_REUSEADDR flag.
'-----------------------------------------------------------
So people trying to port GAMBAS to FreeBSD or other systems will need to
test that socket implementation in their O.S.
Regards,
Daniel Campos
-------------------------------------------------------------
NetCourrier, votre bureau virtuel sur Internet : Mail, Agenda, Clubs, Toolbar...
Web/Wap : www.netcourrier.com
Téléphone/Fax : 08 92 69 00 21 (0,34 TTC/min)
Minitel: 3615 NETCOURRIER (0,16 TTC/min)
More information about the User
mailing list