Up: GEOS SDK TechDocs | Up | Prev: SocketBind() ... | Next: SocketGetAddressController() ...

SocketClose()

SocketError SocketClose(
        Socket 		s);

The SocketClose() routine closes a socket and frees it. Use it to close and free a datagram socket. It is the routine to call when responding to a SE_CONNECTION_CLOSED exception. SocketClose() may be used on a socket in any state, will shut down both outgoing and incoming data, cleans up, and frees the socket.

See Also: SocketCloseSend().

Include: socket.goh

SocketCloseDomainMedium()

SocketError 	SocketCloseDomainMedium(
        char 		*domain, 
        MediumAndUnit 		*mau,
        Boolean		force);

This routine "hangs up" the hardware aspect of a socket connection. You may request that it only do so if there are no socket connections using the medium. If you force the medium closed with socket connections using the medium, the connections will receive no notification (they will just get SE_CONNECTION_RESET errors); therefore, you should force the medium closed only in extreme situations.

This routine takes the following arguments:

domain
Pointer to a string holding the domain name.
mau
Pointer to a MediumAndUnit structure specifying which medium to "hang up".
force
Zero to leave the medium alone if there are active connections using it; non-zero to force the medium closed even with active connections.

Include: socket.goh

SocketCloseSend()

SocketError SocketCloseSend(
        Socket 		s)

The SocketCloseSend() routine only works with connected sockets. (You should always use SocketClose() to close a datagram socket.) It partially shuts down the socket, so that the socket can no longer send data. SocketSend() will return SE_SOCKET_CLOSED if passed such a partially closed socket. However, you can still receive data via the socket--among other things, this means that you can use SocketRecv() to check for an SE_CONNECTION_CLOSED exception. SocketCloseSend() sends an SE_CONNECTION_CLOSED exception packet to the other side of the connection.

Include: socket.goh

SocketConnect()

SocketError SocketConnect(
        Socket 		s,
        SocketAddress 		*addr,
        int 		timeout);

To make a connection, call SocketConnect() . You will pass the socket created via SocketCreate() , the address to connect to, and a timeout value.

You cannot form a true connection using a datagram socket. However, you can use SocketConnect() with a datagram socket to specify a default destination address to use when sending packets.

This routine takes the following arguments:

s
The socket making the connection.
addr
The address to connect to. This must be a primitive address returned by SocketResolve() .
timeout
Time to wait for success, in 1/60 second ticks, or SOCKET_NO_TIMEOUT to try as long as possible.

The SocketConnect() routine returns a SocketError value. If the routine returns SE_NORMAL, then the connection was established successfully. If it returns SE_CONNECTION_REFUSED, the remote site wasn't prepared to accept the connection. If it returns SE_CONNECTION_ERROR, the connection didn't go through for some miscellaneous reason. If it returns SE_NON_UNIQUE_CONNECTION, then you're trying to create a connection that is identical to another connection: same source address, source port, destination address, destination port, and delivery type. There would be no way to tell these connections apart. If you try to open the same connection from both sides simultaneously, they may both fail with SE_NON_UNIQUE_CONNECTION.

Include: socket.goh

SocketCreate()

Socket SocketCreate(
        SocketDeliveryType 			delivery);

To create a new socket, call SocketCreate() . You will need to specify the socket's delivery type: SDT_DATAGRAM, SDT_SEQ_PACKET (sequential packets), or SDT_STREAM. If it returns zero, there was an error: call ThreadGetError() to get the error value, a SocketError .

Include: socket.goh


Up: GEOS SDK TechDocs | Up | Prev: SocketBind() ... | Next: SocketGetAddressController() ...