1. Quick Sockets Question
Hi all,
I'm looking into doing some stuff with WinSockets, and
have so far looked at Jesus Coseugra's thermometer client
as an example. Basically, I just want to test things by
being able to send strings back and forth between several
computers on our network (TCP/IP-based, I believe,) and I
think I'll begin by using his code as an example.
When using the WinSock function, WsockCallSocket(), how
do you broadcast a message to your local network (or is
this not possible using WinSock? I'm just getting into
this...) In other words, I have the program running on
computers A and B. If I start it up on computer C, how
can I signal anyone who's listening that it has been
executed?
Also, other than making sure not to use sockets already
in use for other functions (like telnet, etc.) does the
socket number I choose to use for my program make a
difference?
Rod Jackson
2. Re: Quick Sockets Question
- Posted by Pete Eberlein <xseal at HARBORSIDE.COM>
Dec 02, 1999
-
Last edited Dec 03, 1999
On Thu, 2 Dec 1999 17:58:41 -0600, Roderick Jackson <rjackson at CSIWEB.COM>
wrote:
>Hi all,
>
>I'm looking into doing some stuff with WinSockets, and
>have so far looked at Jesus Coseugra's thermometer client
>as an example. Basically, I just want to test things by
>being able to send strings back and forth between several
>computers on our network (TCP/IP-based, I believe,) and I
>think I'll begin by using his code as an example.
I've got some Linux based Euphoria socket code that uses tcp.
>When using the WinSock function, WsockCallSocket(), how
>do you broadcast a message to your local network (or is
>this not possible using WinSock? I'm just getting into
>this...) In other words, I have the program running on
>computers A and B. If I start it up on computer C, how
>can I signal anyone who's listening that it has been
>executed?
You need to know the broadcast address for your local area net. This is
usually the subnet address bitwise-or'ed with the bitwise-not of the subnet
mask. For example, if your subnet mask is 255.255.255.0 and your ip address
is 100.100.100.100, the broadcast address is probably 100.100.100.255.
>Also, other than making sure not to use sockets already
>in use for other functions (like telnet, etc.) does the
>socket number I choose to use for my program make a
>difference?
Port numbers above 1000 are generally safe to use. There are many
well-known ports that services use. Best thing to do is look in
/etc/services on a unix box and find one that isn't used.
>
>Rod Jackson
Also, Kat, could you post Brians windows socket example? (with his
permission, of course)
Thanks,
Pete
3. Re: Quick Sockets Question
>>When using the WinSock function, WsockCallSocket(), how
>>do you broadcast a message to your local network (or is
>>this not possible using WinSock? I'm just getting into
>>this...) In other words, I have the program running on
>>computers A and B. If I start it up on computer C, how
>>can I signal anyone who's listening that it has been
>>executed?
>
>You need to know the broadcast address for your local area net. This is
>usually the subnet address bitwise-or'ed with the bitwise-not of the subnet
>mask. For example, if your subnet mask is 255.255.255.0 and your ip
address
>is 100.100.100.100, the broadcast address is probably 100.100.100.255.
>
>>Also, other than making sure not to use sockets already
>>in use for other functions (like telnet, etc.) does the
>>socket number I choose to use for my program make a
>>difference?
>
>Port numbers above 1000 are generally safe to use. There are many
>well-known ports that services use. Best thing to do is look in
>/etc/services on a unix box and find one that isn't used.
>
The ports between 49152 and 65535 are designated as private/dynamic ports.
If you want the whole ugly list, go to http://www.isi.edu/in-
notes/iana/assignments/port-numbers
>
>
>Also, Kat, could you post Brians windows socket example? (with his
>permission, of course)
>
Actually, it is posted on my site now, and Rob will update the
Contributions page sometime soon. If you can't wait, the url is
http://2fargon.hypermart.net, and go to the downloads section. You will
find the server demo, and an older POP3 server that is more complex but
more feature-rich as well.
Brian
4. Re: Quick Sockets Question
Pete Eberlein wrote:
>I've got some Linux based Euphoria socket code that uses tcp.
Is that the code where you call functions across
a network? I'll be sure to look into it.
>You need to know the broadcast address for your local area net. This is
>usually the subnet address bitwise-or'ed with the bitwise-not of the subnet
>mask. For example, if your subnet mask is 255.255.255.0 and your ip address
>is 100.100.100.100, the broadcast address is probably 100.100.100.255.
Thanks. I don't suppose there's a way to determine this mask
value through code? Getting the local address I can do...
BTW -- I'll be sure to look at Brian's code as well, it might
already demonstrate how to do this.
Rod Jackson
5. Re: Quick Sockets Question
On Sat, 4 Dec 1999 10:02:42 -0600, Roderick Jackson <rjackson at CSIWEB.COM>
wrote:
>>mask. For example, if your subnet mask is 255.255.255.0 and your ip
>>address
>>is 100.100.100.100, the broadcast address is probably 100.100.100.255.
>
>Thanks. I don't suppose there's a way to determine this mask
>value through code? Getting the local address I can do...
>
Rod:
The subnet mask is 255.255.255.0 on most small networks this would be a
network containing 255 workstations. The subnet mask is used to block out
the upper part of the network address where ever a bit appears the
address that part of the address is blocked out. In the 255.255.255.0
only the lower 255 ( the zero ) are allowed to pass through the mask.
If you have a bigger network then second from the right would be a smaller
value digit. This saves the network software from having to decode the
whole address which would slow the network down.
Bernie
6. Re: Quick Sockets Question
On Sat, 4 Dec 1999 10:02:42 -0600, Roderick Jackson <rjackson at CSIWEB.COM>
wrote:
>Pete Eberlein wrote:
>>I've got some Linux based Euphoria socket code that uses tcp.
>
>Is that the code where you call functions across
>a network? I'll be sure to look into it.
Yup, thats the one. In RDC.e, the socket routines (read,write,connect,etc.)
are not as accessible in the code as I had previously thought. The c_func
calls are hard-coded into read_object/write_object routines, instead of
wrapping the socket functions in their own routine.
I eventually wanted to make RDC handle asynchronous sockets under Linux, but
haven't done enough research into the subject. Having looked at Brians
winsock server example, I am annoyed at how windows-centric the code is. Is
is possible to do asynchronous sockets without a window to get events from?
>>You need to know the broadcast address for your local area net. This is
>>usually the subnet address bitwise-or'ed with the bitwise-not of the
subnet
>>mask. For example, if your subnet mask is 255.255.255.0 and your ip
address
>>is 100.100.100.100, the broadcast address is probably 100.100.100.255.
>
>Thanks. I don't suppose there's a way to determine this mask
>value through code? Getting the local address I can do...
Not really sure how do it from code... under Linux you could exec "ifconfig
-a" and redirect the output to a file and parse it for the mask, but that
seems like an ugly hack.
>BTW -- I'll be sure to look at Brian's code as well, it might
>already demonstrate how to do this.
>
>
>Rod Jackson
Pete