RE: TCP Cannot close my socket directly.... without reason ?
- From: Kun Niu <KunNiu@xxxxxxxxxxxxxxxxxxxxxxxxx>
- Date: Thu, 6 Apr 2006 05:17:01 -0700
How about a udp socket and a tcp socket?
They can be used together.
“Chris”编写:
Hello everybody,.
(I have already do this post, but after a while the previous solution was
not good, so I repost in the forum, sorry)
I contact you because I have some problems with TCP... I have try to find a
solutions, but I cannot find the problem. Maybe I have miss something.
I explain my problem... Here is what my client is doing.
Connection 1
------------
1 - On the client, I create a first socket that is "binded" to port 8900 and
I start the "Accept" on it.
(Yes, my client is also a server)
2 - I create a new "second" socket, bind it to port 8900 (Yes the same port,
I use REUSE_ADDRESS). And I connect to the server.
After this I have a Server and a client socket binded on the same port. It
is because my server
must send me the IP and port of the first socket as seen on the public IP
addresses (behind the NAT).
3 - I close the 2 sockets
Connection 2
------------
1 - On the client, I create a first socket that is "binded" to port 8900 and
I start the "Accept" on it.
(Yes, my client is also a server)
2 - I create a new "second" socket, bind it to port 8900 (Yes the same port,
I use REUSE_ADDRESS). And I connect to the server.
then.....
I got an error "10048" that tell me "Only one usage of each socket address
(protocol/network address/port) is normally permitted".
So I have try this :
1 - I have put Linger to on with a delay of 15 seconds (code is in C#....
but you should understand)
LingerOption lingerOption = new LingerOption(true, 15); // 15 seconds
socket.SetSocketOption(SocketOptionLevel.Socket, SocketOptionName.Linger,
lingerOption);
2 - I have use ReuseAddress :
socket.SetSocketOption(SocketOptionLevel.Socket,
SocketOptionName.ReuseAddress, 1);
Note: If for the second socket I do not bind to the same port, I have no
problem.
I m sure you have understand that I m trying to do the "NAT Hole Punching"
technique ;-)
But.... I can find a way to solve this !!!!! Can you help me, maybe you
already have an idea ?
Thanks for your help, really I appreciate
With Regards
- References:
- Prev by Date: STOPPING WZCSVC with WZCSetInterface
- Next by Date: WSAGetOverlappedResult does not return when breaking physical network connection
- Previous by thread: TCP Cannot close my socket directly.... without reason ?
- Next by thread: Re: TCP Cannot close my socket directly.... without reason ?
- Index(es):
Relevant Pages
|