Portbase User Guide
3.
Windows Socket Program
Basically, the Portbase operates network communication through the socket.
The socket is an effective way to communicate on a network between the client and server.
Programming steps for the socket communication are as follows.
The initial handshaking to support socket communication consists of two methods, Passive and Active.
1) Passive Programming
Set the handshaking method to passive in the Webpage Connection Setting.
Passive handshaking makes the Portbase socket to be on the server side, waiting for a connection
request from the outside.
Portbase’s sockets 4001 to 400x are firmly connected to serial ports 1 to x respectively. For
instance, socket 4002 is conncted to serial port 2.
The server’s waiting sequence for connection requests from client
CAsyncSocket() -----– Create a socket object.
|
Bind() ------------ Announce the program is ready for communication.
|
Listen() ---------- Wait for connection request from client.
|
Receive() ---------- Wait until the client requests a sendto.
|
Send() ------------- Send a HTML file and others in response to the request from client.
2) Active Programming
If you set the handshaking method to active in the Webpage Connection Setting, the socket acts in
Active mode.
Active handshaking makes the Portbase serial ports to be on the client side trying to connect to the
remote client’s IP address and socket number.
If the Portbase has started completely, you can see that sockets 4001 to 400x are automatically
connected to serial ports 1 to x.
108