setsockopt()
Hey,
I have a winsock networking class that works nearly perfectly for my needs.
However, shortly after I recieved MS Visual Studio .NET, I noticed that my socket''s were not being reused after they have been closed.
Inside the constructor of the networking class, I have the following code:
...
setsockopt(iDesc, SOL_SOCKET , SO_REUSEADDR, &yes, sizeof(int));
...
To my knowledge, this should reuse sockets, at least it did previously.
After I am done with a socket, I always perform a closesocket() on it so I am sure that isn''t the problem.
If you need to see some of the code, I will post it here.
Thanks,
Michael Bartman
quote:Original post by TheRealBartmanFor archival reasons, its good practice to give the solution for a question you''ve asked and solved, so others having same or similar issues can learn.
Ok, nevermind.
I figured it out.
It was a problem specific to my custom code, nothing to do with winsock at all.
I will state how I fixed it anyway, though.
My entire project is based on C++ Object Orientation, and I use a lot of pointers.
VS .NET handled some of my pointers differently than VS 6 did, for some reason.
A pointer was being free''d that a method of my network class needed when a player disconnected. This caused a few problems, I just had to change the way some of my pointers were handled.
Michael Bartman
I will state how I fixed it anyway, though.
My entire project is based on C++ Object Orientation, and I use a lot of pointers.
VS .NET handled some of my pointers differently than VS 6 did, for some reason.
A pointer was being free''d that a method of my network class needed when a player disconnected. This caused a few problems, I just had to change the way some of my pointers were handled.
Michael Bartman
Errr...
Actually the SO_REUSEADDR is nothing to do with resuing sockets. read the MSDN documenttation http://msdn.microsoft.com/library/default.asp?url=/library/en-us/wcewinsk/htm/_wcesdk_setsockopt.asp
It actually enabled binding to an address and port which is already bound (which can cause unpredicatable results)
Actually the SO_REUSEADDR is nothing to do with resuing sockets. read the MSDN documenttation http://msdn.microsoft.com/library/default.asp?url=/library/en-us/wcewinsk/htm/_wcesdk_setsockopt.asp
It actually enabled binding to an address and port which is already bound (which can cause unpredicatable results)
quote:Original post by TheRealBartman
Hey,
I have a winsock networking class that works nearly perfectly for my needs.
However, shortly after I recieved MS Visual Studio .NET, I noticed that my socket''s were not being reused after they have been closed.
Inside the constructor of the networking class, I have the following code:
...
setsockopt(iDesc, SOL_SOCKET , SO_REUSEADDR, &yes, sizeof(int));
...
To my knowledge, this should reuse sockets, at least it did previously.
After I am done with a socket, I always perform a closesocket() on it so I am sure that isn''t the problem.
If you need to see some of the code, I will post it here.
Thanks,
Michael Bartman
Yeah if you want to reuse sockets you need to be running Windows XP (or higher) and call DisconnectEx.
or you can call TransmitFile with null for file handler and buffers and specify the disconnect and re-use flags on Windows NT4.0 and 2000 :D
~ Tim
~ Tim
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement