Re: SetSockOpt with SO_REUSEADDR parameter



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
.



Relevant Pages

  • Re: Unable to print to networked printer - get access denied messa
    ... Check the permissions on the server assuming the client has a true RPC ... How is the Standard TCP/IP port configured for the device? ...
    (microsoft.public.windowsxp.print_fax)
  • Re: interfaces lo:1 lo:2 lo:3? (for remote ssh tunnels)
    ... That's the problem tunneling (port forwarding) solves. ... >>can't get past the client firewall. ... > I don't understand why the server would be making the ... server initiates another connection to the client -- in this ...
    (Debian-User)
  • Re: Remote Connection Issue
    ... through port number 3389 and a workstation on the LAN through port number ... I understand that you want to allow a LAN client ... and you have configured server publishing rule ... > By default Terminal Server and Windows 2000 Terminal Services uses TCP ...
    (microsoft.public.windows.server.sbs)
  • Re: RealVNC
    ... Default listening port for RealVNC server that runs on the machine on which ... Then there is default Java listening port on port 5800 on the client machine ...
    (microsoft.public.windows.server.sbs)
  • Re: Redirecting data sent to a local printer to another host and port on the network
    ... All client workstations have access to the ... simply redirecting netcat traffic on port 9100 to port 515 on ... Only LPR clients talk to LPD print server daemons. ... >workstation at the branch site where the print job originated. ...
    (comp.unix.sco.misc)