GEOS SDK TechDocs|
|
3.2 Managing Addresses |
4 Making a Connection SocketGetDomainMedia(), SocketGetAddressMedium(), SocketCheckMediumConnection(), SocketGetMediumAddress(), SocketOpenDomainMedium(), SocketCloseDomainMedium()
Most socket connections involve the use of some hardware "port" -- some physical connection to the outside world. To determine which sort of hardware ports the user's machine uses to connect to a given domain, call
SocketGetDomainMedia()
. This returns a chunk array of
MediumType
structures. Given a choice of domains to make a given connection, consider which medium would be used to make the connection.
To find out which port the Socket library would use to connect to a given address, call
SocketGetAddressMedium()
. Depending on the medium, you might try to connect to the other site via some other domain or decide not to make the connection at all.
To check a given hardware port is being used for an active connection, call
SocketCheckMediumConnection()
. If a point-to-point connection exists, this routine returns the address of the remote site. If there is a connection, but not a specific address, then the routine returns a null address. If there is no connection through the hardware port, the routine returns a
SocketError
value.
To find out the address of the local machine on a connection over a particular medium, use the
SocketGetMediumAddress()
routine. This is the address another machine would use to connect to this machine via that medium.
The
SocketOpenDomainMedium()
routine opens a "raw" connection using the specified medium. Exactly what is meant by a "raw" connection depends upon the domain involved. In the case of TCP, this routine will dial the modem and create a PPP connection to the PPP server but will not send any TCP packets.
It is possible to "hang up" a hardware port. Call
SocketCloseDomainMedium()
to force a domain to close a medium. You may request that the medium only be closed if it is not being used (
i.e.
, there are no active connections using the medium). If any socket connections are using the port, they will receive the error SE_CONNECTION_RESET. Later, we will discuss orderly ways to close a connection, being careful to send proper notification to the other side of the connection.
GEOS SDK TechDocs|
|
3.2 Managing Addresses |
4 Making a Connection