with PB3.94 and UDP userlib from PureFan i can send limited broadcast message to "255.255.255.255" without to know my own ip.
with PB4 (Beta 7) i only can send a directed broadcast ex. 192.168.0.255, but to do so i must know my own ip on lan.
how i can send a limited broadcast message without to know my own ip?
because i use it to find out my own ip on lan by send a coded broadcast message and other global message.
the solution should working on windows and linux also.
UDP Broadcast under PB4 (Beta 7)
Pseudocode
Could be a little slow though 
You could also try to send to 192.168.0.0 because [FIRST 3 IP NUMBERs].0 is the broadcasting number afaik
Code: Select all
For a = 1 to 255
SendUDP(MESSAGE$, "192.168.9." + str(a))
Next

You could also try to send to 192.168.0.0 because [FIRST 3 IP NUMBERs].0 is the broadcasting number afaik

you don't know from stuff i mean, right?
with 192.168.x.255 you already send an udp broadcast message, but its a directed broadcast.
what i want is to send limited broadcast message where ip 255.255.255.255 as target.
when i use
ConnectionID give me zero number as result, and zero mean that connection is failed and can not established.
so, any other way to send limited broadcast? or should i back to PBv3.94 with PureFan UDP userlib.
with 192.168.x.255 you already send an udp broadcast message, but its a directed broadcast.
what i want is to send limited broadcast message where ip 255.255.255.255 as target.
when i use
Code: Select all
ConnectionID.l = OpenNetworkConnection("255.255.255.255", 5000, #PB_Network_UDP)
so, any other way to send limited broadcast? or should i back to PBv3.94 with PureFan UDP userlib.
Hi Charlie,
take a look into your thread in the german forum... I posted a brand new userlib (and the smallest one ever, I think
) for PB4 with only 1 function - SendUDPBroadcast(Port, Message$). It enables you to send messages via UDP to IP 255.255.255.255.
If I think about the problem with OpenNetworkConnection:
Sending messages to broadcasts and multicasts requires the use of a generic sendto() function without need to connect to a server. You MUST NOT connect to a broadcast-IP, because a wide range of "servers" get the message and handle it.
For interested users in this forum: It's up to you to try the lib - download it on http://www.cornycountry.de! At the moment it's commented in german, but in a few minutes it will be available with english comments, too.
take a look into your thread in the german forum... I posted a brand new userlib (and the smallest one ever, I think

If I think about the problem with OpenNetworkConnection:
Sending messages to broadcasts and multicasts requires the use of a generic sendto() function without need to connect to a server. You MUST NOT connect to a broadcast-IP, because a wide range of "servers" get the message and handle it.
For interested users in this forum: It's up to you to try the lib - download it on http://www.cornycountry.de! At the moment it's commented in german, but in a few minutes it will be available with english comments, too.
No - that's why the lib is that kind of small. :roll: The reason for creating a library is simply to write one, because I didn't know how to do... Charlie mentioned (in the german forum) the UPDlib for PB 3.94 and I wanted to make a try with an interesting background. If you look into the source you should know what to bundle into a working udp-broadcast-FUNCTION (for example):
1. you have to create a socket_()
2. you have to setsockopt_() to allow broadcasts
3. you have to set the destination IP to broadcast IP
4. you have to sendto_() a message to the built socket
5. you have to closesocket_() the socket.
If you don't like my lib (I take it personal
), use this procedure to send a udp broadcast:
Greets
René
1. you have to create a socket_()
2. you have to setsockopt_() to allow broadcasts
3. you have to set the destination IP to broadcast IP
4. you have to sendto_() a message to the built socket
5. you have to closesocket_() the socket.
If you don't like my lib (I take it personal

Code: Select all
Procedure.l SendUDPBroadcastL (port, message.s)
Protected sock,one,bytes,remote.sockaddr_in
sock = SOCKET_(#AF_INET,#SOCK_DGRAM,#IPPROTO_IP)
If ( sock = -1) : ProcedureReturn 1 : EndIf
one = 1
If (setsockopt_(sock,#SOL_SOCKET,#SO_BROADCAST,@one,SizeOf(one)) = -1)
ProcedureReturn 1
EndIf
remote\sin_family = #AF_INET
remote\sin_port = htons_(port)
remote\sin_addr = #INADDR_BROADCAST
if (sendto_(sock,message,Len(message),0,@remote,SizeOf(remote)) = -1)
ProcedureReturn 1
EndIf
closesocket_(sock)
ProcedureReturn 0
EndProcedure
René