Linux Socket Programming by Example - Warren Gay

< BACKCONTINUE >
159231153036212041242100244042145096184016146223183074028121223008110135077000161100030000175

Demonstrating the Broadcasts

With the server and client programs compiled, you are ready to begin. The first example sessions should work for everyone, with or without a network established. The demonstration will make use of the local loopback interface that every Linux system should have available unless it has been disabled.

The first step is to start the broadcast server:

					
@pepper
$ ./stksrv 127.255.255.255:9097 &
[1] 756
@pepper
$
				

The session shows the starting of the stksrv server program on the host system pepper. The client session on the same host looked like this:

					
$ ./gquotes 127.255.255.255:9097
DJIA    10302.06 -1.24
NASDAQ   2766.86 +5.11
S&P 500  1285.48 +2.17
TSE 300  6897.99 +2.27

DJIA    10302.06 -1.24
NASDAQ   2766.86 +5.11
S&P 500  1285.73 +2.42
TSE 300  6897.99 +2.27

DJIA    10302.06 -1.24
NASDAQ   2766.86 +5.11
S&P 500  1286.00 +2.69
TSE 300  6897.99 +2.27

[CTRL+C]
@pepper
$
				

In the client session shown, the program was allowed to provide three quote updates before CTRL+C was typed to end its execution (your interrupt character might be different). Note that the broadcast address and port number must agree for both the client and server.

To prove to yourself that a broadcast is being performed, and not simply a point-to-point communication, you can start multiple instances of the client program. When this is done, they will all update at approximately the same time.

< BACKCONTINUE >

Index terms contained in this section

broadcasts
      demonstrating
      establishing
demonstrating
      broadcasts
establishing
     servers
            broadcasts
programs
      stksrv server 2nd
starting
      stksrv server program 2nd
stksrv server program
      starting 2nd