Udvari András László wrote: Resuse the same port. Create the component once and reuse it. You then also need to use the SendTo method rather than the Send function.
From glibc documentation: "The normal way of sending data on a datagram socket is by using the |sendto| function, declared in sys/socket.h. You can call |connect| on a datagram socket, but this only specifies a default destination for further data transmission on the socket. When a socket has a default destination you can use |send| (see Sending Data <http://www.gnu.org/software/libc/manual/html_node/Sending-Data.html#Sending-Data>) or even |write| (see I/O Primitives <http://www.gnu.org/software/libc/manual/html_node/I_002fO-Primitives.html#I_002fO-Primitives>) to send a packet there. You can cancel the default destination by calling |connect| using an address format of |AF_UNSPEC| in the addr argument. See Connecting <http://www.gnu.org/software/libc/manual/html_node/Connecting.html#Connecting>, for more information about the |connect| function." HTH > Hi! > > I have a client-server application, where the server sends UDP datagrams to > the client, and the client measures the speed of the channel. These datagrams > are sent using the following code: > > case userid of > 1: begin us:=mainform.udpsock1;us.LocalPort:='4001';end; > 2: begin us:=mainform.udpsock2;us.LocalPort:='4002';end; > 3: begin us:=mainform.udpsock3;us.LocalPort:='4003';end; > 4: begin us:=mainform.udpsock4;us.LocalPort:='4004';end; > 5: begin us:=mainform.udpsock5;us.LocalPort:='4005';end; > 6: begin us:=mainform.udpsock6;us.LocalPort:='4006';end; > 7: begin us:=mainform.udpsock7;us.LocalPort:='4007';end; > 8: begin us:=mainform.udpsock8;us.LocalPort:='4008';end; > 9: begin us:=mainform.udpsock9;us.LocalPort:='4009';end; > 10: begin us:=mainform.udpsock10;us.LocalPort:='4010';end; > end; > us.Proto:='udp'; > us.Addr:=remoteip[userid]; > us.Port:=remoteport[userid]; > us.Connect; > us.Send(sendbuffer[userid],blocksize[userid]); > us.Close; > > > My problem is: I want that the server only uses one port for sending these > datagrams (to save resources), that's what I tried to set in LocalPort > property. But there is no use of this, the server gives a new source port > randomly for every datagram between 4000 and 5000. The destination port on > the client side is constantly 5000, that is what I set. > > Is there any way to limit the server side to use just one port for sending, > then reuse the same port? There are about 5-10 datagrams sent per second, so > we run out of resources quite quickly. > > > Thanks for your help: > Andras > -- To unsubscribe or change your settings for TWSocket mailing list please goto http://www.elists.org/mailman/listinfo/twsocket Visit our website at http://www.overbyte.be