Re: SetSockOpt with SO_REUSEADDR parameter
- From: Norbert Unterberg <nunterberg@xxxxxxxxxxxxxxxxx>
- Date: Fri, 23 Mar 2007 08:05:49 +0100
mmlab_js schrieb:
I override the CASyncSocket::Create to solve this problem.
Why is it so important to you to use the SAME source port number for all clients? What is the *real* problem you are trying to solve? I simply do not believe your boss told you to use the same server socket and port number for all client streaming data. So what is the real issue?
Usually, when doing things liek this and I need one socket per "connection", then I bind the local socket to PORT_ANY because I do not care. WHat is important is that the destination port number is correct, usually not the source port number.
When using TCP, the source port number is usually totally irrelevant, what counts is the destination port when creating a connection. When a server accepts a TCP connection, a new socket is created with a totally new and unrelated server port number. Why do you insist on using the same server port number for all your UDP traffic when even TCP does not do it that way?
Do you really understand the concept of source and destination port number, the difference between these two, and how TCP and UDP handle them?
The client can detect whether a received packet comes from the correct server by looking at the source address in this case. If you really need to check the source port, then tell the client the automatically generated port number over the TCP control connection that the server seems to haver to the client.
==========================================
BOOL CUdpSendSocket::Create(UINT nSocketPort, int nSocketType, long lEvent, LPCTSTR lpszSocketAddress)
{
if (Socket(nSocketType, lEvent)) {
BOOL bMultipleApps = TRUE; SetSockOpt(SO_REUSEADDR, (void*)&bMultipleApps, sizeof(BOOL), SOL_SOCKET);
You are still doing things with UDP and sockets here what they are not designed for.
Norbert
.
- Follow-Ups:
- Re: SetSockOpt with SO_REUSEADDR parameter
- From: Joseph M . Newcomer
- Re: SetSockOpt with SO_REUSEADDR parameter
- References:
- Re: SetSockOpt with SO_REUSEADDR parameter
- From: Joseph M . Newcomer
- Re: SetSockOpt with SO_REUSEADDR parameter
- From: mmlab_js
- Re: SetSockOpt with SO_REUSEADDR parameter
- From: Norbert Unterberg
- Re: SetSockOpt with SO_REUSEADDR parameter
- Prev by Date: Re: Get Folder from Full File Path
- Next by Date: Re: Who generates the endless WM_PAINT message
- Previous by thread: Re: SetSockOpt with SO_REUSEADDR parameter
- Next by thread: Re: SetSockOpt with SO_REUSEADDR parameter
- Index(es):
Relevant Pages
|