Enhancement in UDP for newlisp [ broadcast ]

Q&A's, tips, howto's
Locked
newdep
Posts: 2038
Joined: Mon Feb 23, 2004 7:40 pm
Location: Netherlands

Enhancement in UDP for newlisp [ broadcast ]

Post by newdep »

Hello Lutz,

Is it an Idea to enhance the UDP functionality with SO_BROADCAST ?
The setsockopt needs an #SO_BROADCAST $0020 and a #SOL_SOCKET $FFFF in that case and a newllist function like net-broadcast-udp ( int-socket ) will enable/disable broadcast on the UDP socket. I had a look in your great C code but did not dare to touch it myself ;-)

* just tried it but got stuck ;-)

Regards, Norman.

Lutz
Posts: 5289
Joined: Thu Sep 26, 2002 4:45 pm
Location: Pasadena, California
Contact:

Post by Lutz »

Sounds like a good idea, I will give it a try.

Lutz

newdep
Posts: 2038
Joined: Mon Feb 23, 2004 7:40 pm
Location: Netherlands

Post by newdep »

Hello Lutz,

Add-on, for the use of broadcast it should be able to be enabled on both
sending and receiving on udp.. Would be great to have it...

Regards, Norman.

Lutz
Posts: 5289
Joined: Thu Sep 26, 2002 4:45 pm
Location: Pasadena, California
Contact:

Post by Lutz »

Hi Norman,

just finished implementing an additional parameter for 'net-listen'

example:

(net-listen 1234 "192.168.0.5") ;; or name for IP

Unfortunately I don't have a computer with two net work cards, but the code was streight forward enough that I think it will work. The version will go up with a couple of other changes/fixes as 7.5.5 in a couple of days.

Regarding the broadcast thing for UDP I am not shure what to specify for SO_BROADCAST boolean
char * optval
int * oplen

On UNIX man pages I read that a non-zero int value would be specified for boolean TRUE (not int * ), but what about int * oplen? just NULL ?

setsockopt(mysocket, SOL_SOCKET, SO_BROADCAST, 1, NULL) ?

Lutz

newdep
Posts: 2038
Joined: Mon Feb 23, 2004 7:40 pm
Location: Netherlands

Post by newdep »

Hello Lutz,

for the setsockopt i use this,

setsockopt(mysocket, SOL_SOCKET, SO_BROADCAST, 1)

The optlen is optional and will be NULL when not provided using setsockopt automaticly, for getsockopt i though it returns the Buffer lenght from optvalue. The option optval it is indeed Non-Zero (1) to enable it and Zero to disable it.

Regards, Norman.

newdep
Posts: 2038
Joined: Mon Feb 23, 2004 7:40 pm
Location: Netherlands

Post by newdep »

Hello Lutz,

A little tip on the (net-listen 1234 "192.168.0.5")

Could you perhpas turn it around like: (net-listen "192.168.168.1" 1234) ?

Ill see My other machine are up and running for newlisp, i could test
the code for you, no problem.

Norman.

Lutz
Posts: 5289
Joined: Thu Sep 26, 2002 4:45 pm
Location: Pasadena, California
Contact:

Post by Lutz »

>>>>>
Could you perhpas turn it around like: (net-listen "192.168.168.1" 1234) ?
>>>>>

this would break compatibility with previous code, also the additional address is an optional parameter which doesn't need to be specified, so it is better having it at the end.

thanks for the SO_BROADCAST clarification

Lutz

newdep
Posts: 2038
Joined: Mon Feb 23, 2004 7:40 pm
Location: Netherlands

Post by newdep »

followup from "Warning" in lisp general...


Im testing here between win2000 and linux and between linux linux but
nothing
happens I think its between your Windows version where it could be enabled on one of them, on Win98 the setsockopt need the extra NULL at the end i think because win98 is slighty different on Sockets...

Norman.

Locked