Re: [twsocket] UDP question...
This is the first time I am writing a UDP server. The other UDP was a client. It was fairly straight forward. As the server lets say I have 2 clients, A and B, that will be sending me unsolicited data of 100 bytes per message. If I understand, when TWSocket.OnDataAvailable fires the data source can be mixed. For example I could get 10 bytes from A, then 19 bytes from B, then 14 bytes from B and then 56 bytes from A, etc. And I might not get the hundred bytes. I might only get 45. No, this is wrong. UDP is a datagram protocol. Datagram boundaries are respected. If you send 100 bytes (in one call to Send of course), you'll receive exactly 100 bytes in one call to Receive done from one OnDataAvailable event. There are a few things you must pay attention: TWSocket.BufSize must be large enough for your larger datagram (It default to 1460 bytes); when calling Receive or ReceiveFrom (to know who sent the packet), you must pass a bufer larger enough; not all physical networks are able to send any arbitrary large datagram. There is a limit imposed by each network. This is totally diffrent for TCP which is a stream protocol. For a complete description, see TCP/UDP primer document available from my website. -- [EMAIL PROTECTED] The author of the freeware multi-tier middleware MidWare The author of the freeware Internet Component Suite (ICS) http://www.overbyte.be -- To unsubscribe or change your settings for TWSocket mailing list please goto http://lists.elists.org/cgi-bin/mailman/listinfo/twsocket Visit our website at http://www.overbyte.be
Re: [twsocket] UDP question...
I think with UDP you get can get packets in different order, not get them at all, get them repeated.. but as opposed to TCP you get entire packets, if you send 100 bytes at once, you get 100 at once. Someone correct me if I'm wrong.. You are right. -- [EMAIL PROTECTED] The author of the freeware multi-tier middleware MidWare The author of the freeware Internet Component Suite (ICS) http://www.overbyte.be -- To unsubscribe or change your settings for TWSocket mailing list please goto http://lists.elists.org/cgi-bin/mailman/listinfo/twsocket Visit our website at http://www.overbyte.be
Re: [twsocket] UDP question...
Thanks for the answer and the link. This has now become a bit easier task. One last question. The PC has several network cards and the networks are completely separate. I need to handle datagrams from all networks. I have a TWSocket with addr set to 0.0.0.0 and localAddr is blank. I assume this will allow me to listen on all networks. I get the source address using ReceiveFrom and use SendTo to send the response. That all sound good? Thanks, Mark -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Francois PIETTE Sent: Tuesday, July 22, 2008 3:13 AM To: ICS support mailing Subject: Re: [twsocket] UDP question... This is the first time I am writing a UDP server. The other UDP was a client. It was fairly straight forward. As the server lets say I have 2 clients, A and B, that will be sending me unsolicited data of 100 bytes per message. If I understand, when TWSocket.OnDataAvailable fires the data source can be mixed. For example I could get 10 bytes from A, then 19 bytes from B, then 14 bytes from B and then 56 bytes from A, etc. And I might not get the hundred bytes. I might only get 45. No, this is wrong. UDP is a datagram protocol. Datagram boundaries are respected. If you send 100 bytes (in one call to Send of course), you'll receive exactly 100 bytes in one call to Receive done from one OnDataAvailable event. There are a few things you must pay attention: TWSocket.BufSize must be large enough for your larger datagram (It default to 1460 bytes); when calling Receive or ReceiveFrom (to know who sent the packet), you must pass a bufer larger enough; not all physical networks are able to send any arbitrary large datagram. There is a limit imposed by each network. This is totally diffrent for TCP which is a stream protocol. For a complete description, see TCP/UDP primer document available from my website. -- [EMAIL PROTECTED] The author of the freeware multi-tier middleware MidWare The author of the freeware Internet Component Suite (ICS) http://www.overbyte.be -- To unsubscribe or change your settings for TWSocket mailing list please goto http://lists.elists.org/cgi-bin/mailman/listinfo/twsocket Visit our website at http://www.overbyte.be -- To unsubscribe or change your settings for TWSocket mailing list please goto http://lists.elists.org/cgi-bin/mailman/listinfo/twsocket Visit our website at http://www.overbyte.be
Re: [twsocket] UDP question...
Thanks for the answer and the link. This has now become a bit easier task. One last question. The PC has several network cards and the networks are completely separate. I need to handle datagrams from all networks. I have a TWSocket with addr set to 0.0.0.0 and localAddr is blank. I assume this will allow me to listen on all networks. I get the source address using ReceiveFrom and use SendTo to send the response. That all sound good? Yes, very good. Contribute to the SSL Effort. Visit http://www.overbyte.be/eng/ssl.html -- [EMAIL PROTECTED] The author of the freeware multi-tier middleware MidWare The author of the freeware Internet Component Suite (ICS) http://www.overbyte.be -- To unsubscribe or change your settings for TWSocket mailing list please goto http://lists.elists.org/cgi-bin/mailman/listinfo/twsocket Visit our website at http://www.overbyte.be
Re: [twsocket] UDP question...
I think with UDP you get can get packets in different order, not get them at all, get them repeated.. but as opposed to TCP you get entire packets, if you send 100 bytes at once, you get 100 at once. Someone correct me if I'm wrong.. Hi, This is the first time I am writing a UDP server. The other UDP was a client. It was fairly straight forward. As the server lets say I have 2 clients, A and B, that will be sending me unsolicited data of 100 bytes per message. If I understand, when TWSocket.OnDataAvailable fires the data source can be mixed. For example I could get 10 bytes from A, then 19 bytes from B, then 14 bytes from B and then 56 bytes from A, etc. And I might not get the hundred bytes. I might only get 45. This lead to keeping separate state machines for each client. With TCP I normally read the data to the client buffer and post a message so that OnDataAvailable is as short as possible. In this case it appears I need to read it to a buffer, determine the client, move the data to the clients buffer and post a message. Sound about right? Ciao, Mark -- To unsubscribe or change your settings for TWSocket mailing list please goto http://lists.elists.org/cgi-bin/mailman/listinfo/twsocket Visit our website at http://www.overbyte.be -- To unsubscribe or change your settings for TWSocket mailing list please goto http://lists.elists.org/cgi-bin/mailman/listinfo/twsocket Visit our website at http://www.overbyte.be