GEOS SDK TechDocs|
|
10 Domain-Specific Information |
10.2 TCP/IP--Standard The TCP/IP domain is a popular standard used for internet communications. The GEOS-specific version supports 32-bit port numbers. GEOS TCP/IP data may be transmitted via a regular TCP/IP network, though both the sending and receiving machines must support GEOS TCP/IP.
TcpAccPntExtendedAddress
,a
TcpOnlyExtendedAddress
, or a
TcpNonAccPntExtendedAddress
.
SocketOpenDomainMedium()
with the TCP medium creates a PPP connection. The modem will dial, and the machine will connect to the PPP server, but no TCP level packets will be sent. If the PPP connection is already made, this routine will return SE_NORMAL, just as if the connection had been just now made. If the modem is already in use, an SE_MEDIUM_BUSY error will be returned. Use the
SocketCloseDomaninMedium()
to hang up the phone when done.
MSG_GEN_GUP_INTERACTION_COMMAND
, which queries the AccessPointControl for the selected ISP and extracts the useful information about that ISP; finally, the MSG_CTP_CONNECT handler dials the phone to make the PPP connection.)Code Display 23-2 Making the Raw TCP/IP Connection
Here we see three snippets of code from the Talk sample application
The AccessPointControl allows the user to choose an ISP:
@chunk char accpntMkr[] = "Access List";
@object AccessPointControlClass AccpntControl = {
GI_states = GS_USABLE|GS_ENABLED;
HINT_ACCESS_POINT_CONTROL_MINIMIZE_SIZE;
ATTR_ACCESS_POINT_CONTROL_LIST_MONIKER = @accpntMkr; }
In @method TalkAddressClass, MSG_GEN_GUP_INTERACTION_COMMAND, we get information we'll need about the ISP
point = @call \ GeodeGetOptrNS(@AccpntControl)::MSG_ACCESS_POINT_CONTROL_GET_SELECTION();
/* store link info into address buffer */ rawAddress.UTA_link.TAPEA_linkSize = 3; rawAddress.UTA_link.TAPEA_linkType = LT_ID; rawAddress.UTA_link.TAPEA_accPntID = point;
/* the text of the address follows the link info */ alen = @call GeodeGetOptrNS(@IPText)::MSG_VIS_TEXT_GET_ALL_PTR( (char *)&(rawAddress.UTA_ip[0]));
if (alen > MAX_IP_ADDR_STRING_LENGTH) FatalError(0); /* too much text */
/* resolve the raw address into a SocketAddress */ theAddress.SA_addressSize = SocketResolve(theAddress.SA_domain, (byte *)(&rawAddress), sizeof(TcpAccPntExtendedAddress)+alen, (byte *)(&addressBuffer), MAX_ADDRESS_SIZE);
In MSG_CTP_CONNECT's handler, we make the PPP connection:
rval = SocketOpenDomainMedium((SocketAddress *) &theAddress, SOCKET_NO_TIMEOUT);
If you set the SSF_URGENT flag to
SocketSend()
when sending a multi-byte packet, the last byte of the packet will be marked urgent.
Recall that you can set the in-line option to specify that urgent data should be treated as normal data. In this case, urgent data will be treated as a normal 1-byte packet.
#define ECHO 7 /* TCP/UDP */ #define DISCARD 9 /* TCP/UDP */ #define FTP_DATA 20 /* TCP */ #define FTP 21 /* TCP */ #define TELNET_SERVER 23 /* TCP */ #define NAME_SERVER 42 /* UDP */ #define WHOIS 43 /* TCP */ #define DOMAIN_SERVER 53 /* TCP/UDP */ #define FINGER 79 /* TCP */
SocketAddress
structure takes the following form for the TCP domain:typedef struct {
word TOEA_linkSize; /* 0 */
byte TOEA_ipAddr[4]; /* IP address */
} TcpOnlyResolvedAddress;
A variation on this structure is used for storing the address information for a TCP access point address. Along with the address information, there are three bytes of information about the nature of the link: the first of these bytes should have value LT_ID, so that the driver will know that the next two bytes represent a link ID; the other two bytes should be the access point's ID.
typedef struct {
word TAPRA_linkSize; /* 3 */
byte TAPRA_linkType; /* LinkType (LT_ID) */
word TAPRA_accPntID;
byte TAPRA_ipAddr[4]; /* IP address */
} TcpAccPntResolvedAddress;
GEOS SDK TechDocs|
|
10 Domain-Specific Information |
10.2 TCP/IP--Standard