[Gambas-user] UDP socket component & UDP broadcasts

p.r. faasse faasse at ...1252...
Mon Dec 5 10:52:20 CET 2005


On Friday 02 December 2005 22:37, Daniel Campos wrote:
> Hi:
> 
> Could you send me your patch? I will add it!
> 
> thanks,
> 
> D. Campos

Gladly. Should i mail it here, or somewhere else? It is currently the only change i've made to Gambas,
so i'll have to beg indulgance for the inexperienced way i went about it :-) On the same note (and having seen
Bienot's comments w.r.t. properties/socket component), there are a few other socket options you might
want to consider:

- UDP: SO_BROADCAST: as described before: without it you will not be allowed to do broadcasts. I can
  not really think of any reason to forbid this, but wiser men may say otherwise. This option makes sense
  for UDP only (as far as i can tell that is :-).
- UDP/TCP: SO_REUSEADDRESS: May save you the 4-minutes 'wait-time' when a server crashes. With 
  REUSEADDRESS you can restart a 'bind-ed' server immediately, without it you get 'address in use' errors for the first
  4 minutes (=time-wait time), then you can reactivate the server. I'm not sure if this is always a good idea, but
  in 'C' i've been using this socket option for quite some time for all servers and have not seen a reason not to use it yet.
- TCP: SO_NOWAIT: Is somewhat more subtle; I use it when i want to communicate over TCP using small packets.
  'Normal' TCP has the 'privilege' to 'pack' more of these small transmissions into one 'full' IP packet before actually 
  sending out the data onto the net. With SO_NOWAIT you tell the stack that you want the data to be transmitted 
  immediately. I use this when i -for instance- do status polls of a device over a network at -say- 10 Hz. In this kind 
  of situation I want the stack to not 'join-up' more status poll requests into one packet, but to send each 'write' to 
  the actual network because i want one answer from the device for each status poll transmission. I think that this 
  option is not something you should want to impose on all TCP sockets, but it is the only way i know of to get 
  something like the status polls i've described above to work good :-)

No critisism intended, but the current socket component implementation does not give access to socket options.
Perhaps the 'right way' to go about it would be to implement a socket option interface instead of hard-coding some 
socket options themselves into the socket component. The default behaviour of sockets is quite well-tuned for what
appears to be the 'standard use' of sockets, and socket options seem to be intended to permit fine-tuning the TCP 
stack's behaviour to specific needs (such as mine :-). 
  
Unless told otherwise, i'll get my modified source of 'socket.c', and include it into a mail here, That will be tomorrow, 
i'm not at the Gambas development machine at this moment... :-(

> 2005/11/29, p.r. faasse <faasse at ...1252...>:
> >
> > When I tried to do UDP broadcasts (Gambas-1.0.13) I got a 'permission
> > denied'.
> >
> > I have solved by adding the SO_BROADCAST/setsockopt in the source of the
> > Gambas
> > network UDP component and re-compiling Gambas itself. Is there any way i
> > could make the
> > developers add this to the network component by default?
> >
> >
> >
> > -------------------------------------------------------
> > This SF.net email is sponsored by: Splunk Inc. Do you grep through log
> > files
> > for problems?  Stop!  Download the new AJAX search engine that makes
> > searching your log files as easy as surfing the  web.  DOWNLOAD SPLUNK!
> > http://ads.osdn.com/?ad_id=7637&alloc_id=16865&op=click
> > _______________________________________________
> > Gambas-user mailing list
> > Gambas-user at lists.sourceforge.net
> > https://lists.sourceforge.net/lists/listinfo/gambas-user
> >





More information about the User mailing list