61
communication does not end until either end closes the connection or sends a null
character string.
Process Diagram of Server Program
2.
Client
It is easier to create a TCP client than to do a server. Take the following
pseudocode:
c
=
socket
( )
# Create a client socket.
c
.
connect
( )
# Try to connect a server.
comm_loop
:
# Communication loop.
c
.
send
( )/
c
.
recv
( )
# Dialog (sending out and receiving data)
c
.
close
( )
# Close the client socket.
As mentioned above, all sockets are created via the function
socket.socket( )
. Then,
the function
connect( )
can be called to connect the server. After the connection is
built, the dialog between the client and the server is enabled. When the dialog ends,
the client can close the socket and the connection.