Skip to end of metadata
Go to start of metadata

You are viewing an old version of this page. View the current version.

Compare with Current View Page History

« Previous Version 2 Next »

Page 382 of the tutorial introduces socket programming. 

As the tutorial explains, a socket "is a communication resource used by the applications to communicate between computers regardless of the network type". 

Essentially, with sockets you can set up your own network communication channels to manage private communication between your applications or to connect to outside servers or clients. 

The "WD using sockets" example shows one way to manage client/server communication. If you run the executable (which I suggest you do via Windows Explorer or a command prompt, as you'll need to run more than one copy) you'll see this window:

I started off with a server, and got this:

I then launched another instance and ran it as a client:

and got this window:

I launched two more clients, each one with a different value in the Login field, and started sending some messages around:

 

 

Sockets are communication endpoints; to do socket communication you need two sockets, each of which is identified by a combination of IP address and port number. 

Communication between sockets has to follow some sort of protocol, so the code at each end knows how to interpret the packets of data that arrive at the socket. There are a number of standardized port/protocol combinations, such as:

 

 

- you establish communication between two applications which may be running on the same device, or which may be on separate computers on one network, or which may be on opposite sides of the planet. In all cases, 

  • No labels