/MEng/System/Runtime/Socket| ClassPath: | MEng.System.Runtime.Socket | | Parent ClassPath: | MEng.Object | | Copyable: | No | | Final: | No (Abstract) |
MEng.System.Runtime.Socket is the base class for a set of socket classes which implement various types of client or server, stream or datagram sockets. This class provides the core methods that apply to any type of socket, mostly related to setting socket flags such as route, linger, keep alive, and so forth. This class also defines some errors that are thrown by all of it's derivatives. Nested Classes:
Enum=SocketErrors
AlreadyBound : "The socket is already bound";
NotBound : "The socket must be bound to do this";
BindFailed : "The socket could not be bound";
AlreadyConn : "The socket is already connected";
NotConn : "The socket is not connected";
ConnFailed : "";
Unsupported : "";
ConnAborted : "";
Timeout : "";
OtherSideClosed : "";
NetworkUnreachable : "";
NetworkDown : "";
ConnRefused : "";
ConnReset : "";
DGramBufToSmall : "";
HostUnreachable : "";
NameTooLong : "";
ReadErr : "";
ShutdownErr : "";
UnknownErr : "";
WriteErr : "";
EndEnum;This enumerated type defines the socket specific exceptions that this class and it's derivatives might throw. Note though that other exceptions might be thrown from other classes used by this class or passed into the methods of this class, and some common exceptions from MEng.Object might be thrown. Note that some of them have no associated text because the actual text reported comes from the underlying C++ error that occurred.
Enum=SockProtos
IP : "IP";
ICMP : "ICMP";
IGMP : "IGMP");
TCP : "TCP";
PUP : "PUP";
UDP : "UDP";
IDP : "IDP";
RawIP : "RawIP";
EndEnum;This enumerated type defines the socket protocols that you want your socket to use. A description of the meanings of these protocols are beyond the scope of this document. Mostly though you will either use IP, TCP, or UDP.
Constructors:
Constructor(); There is just a default constructor available, which is only callable by derived classes, since this is an abstract class.
Final, Const Methods:
GetDataIsReady([Out] MEng.Card4 BytesAvail) Returns MEng.Boolean; Returns True if there is data ready to be read on the socket. For a datagram socket, this means at least one datagram is available. For stream sockets, at least a byte of data is available. The number of bytes available is returned in the BytesAvail parameter. For a datagram this will be the size of the packet. For a stream socket, more data might have arrived by the time you get to read it, so the value is only advisory. If the socket isn't bound, it will throw a SocketErrors.NotBound exception.
GetLocalEndPoint() Returns MEng.System.Runtime.IPEndPoint; Returns the local end point to which this socket is bound. If the socket is not bound yet, it will throw the NotBound exception.
GetIsBound() Returns MEng.Boolean; Returns a Boolean value that indicates whether the socket is bound to a local end point yet or not.
Final, Non-Const Methods:
GetStatus
(
[Out] MEng.Boolean Readable
, [Out] MEng.Boolean Writable
, [Out] MEng.Boolean Excepts
, [In] MEng.Card4 WaitMillis
);This method will wait up to WaitMillis milliseconds for at least one state to become true for this socket, and will return the states found. If Readable is True, then either data is available, or in a stream socket the other side has done a clean shutdown (if you read and get zero bytes, that's what it was), or a datagram is available on a datagram socket. If Writable is True, then data is in the outgoing buffer. If Excepts is True, then exceptions have occurred on the socket that haven't been cleared. If the socket isn't bound, it will throw a SocketErrors.NotBound exception.
SetKeepAlive([In] MEng.Boolean NewState); Sets the keep alive flag on this socket to the passed new state. True turns on the keep alive functionality, where the low level socket logic will send period messages to the other side, to ensure the link stays up, despite sporadic higher level traffic. False will turn off this functionality.
SetLinger([In] MEng.Boolean NewState, [In] MEng.Card4 Millis); Sets the linger flag on this socket to the passed new state. True turns on the linger, and the Millis flag indicates the linger time. False turns it off and the Millis flag is ignored. If the socket isn't bound, it will throw a SocketErrors.NotBound exception.
WaitForData([In] MEng.Card4 WaitMillis) Returns MEng.Boolean; Waits for up to WaitMillis milliseconds for data to arrive on the socket. If data arrives before the timeout period, it will return True. Else, it will return False. If the socket isn't bound, it will throw a SocketErrors.NotBound exception.
|