TSocket
class description - source file - inheritance tree
private:
virtual Option_t* GetOption() const
void operator=(const TSocket&)
void SetDescriptor(Int_t desc)
protected:
TSocket TSocket()
public:
TSocket TSocket(TInetAddress address, Int_t port)
TSocket TSocket(const char* host, const char* service)
TSocket TSocket(const char* host, Int_t port)
TSocket TSocket(TInetAddress address, const char* service)
TSocket TSocket(Int_t descriptor)
TSocket TSocket(const TSocket& s)
virtual void ~TSocket()
TClass* Class()
virtual void Close(Option_t* opt)
UInt_t GetBytesRecv() const
UInt_t GetBytesSent() const
Int_t GetDescriptor() const
Int_t GetErrorCode() const
TInetAddress GetInetAddress() const
virtual TInetAddress GetLocalInetAddress()
virtual Int_t GetLocalPort()
virtual Int_t GetOption(ESockOptions opt, Int_t& val)
Int_t GetPort() const
UInt_t GetSocketBytesRecv()
UInt_t GetSocketBytesSent()
virtual TClass* IsA() const
Bool_t IsValid() const
virtual Int_t Recv(TMessage*& mess)
virtual Int_t Recv(char* mess, Int_t max, Int_t& kind)
virtual Int_t Recv(char* mess, Int_t max)
virtual Int_t RecvRaw(void* buffer, Int_t length, ESendRecvOptions opt = kDefault)
virtual Int_t Send(const char* mess, Int_t kind = kMESS_STRING)
virtual Int_t Send(const TMessage& mess)
virtual Int_t Send(Int_t kind)
virtual Int_t SendObject(const TObject* obj, Int_t kind = kMESS_OBJECT)
virtual Int_t SendRaw(const void* buffer, Int_t length, ESendRecvOptions opt = kDefault)
virtual Int_t SetOption(ESockOptions opt, Int_t val)
virtual void ShowMembers(TMemberInspector& insp, char* parent)
virtual void Streamer(TBuffer& b)
private:
TInetAddress fLocalAddress local internet address and port #
UInt_t fBytesSent total bytes sent using this socket
UInt_t fBytesRecv total bytes received over this socket
static UInt_t fgBytesSent total bytes sent by all socket objects
static UInt_t fgBytesRecv total bytes received by all socket objects
protected:
Int_t fSocket socket descriptor
TString fService name of service (matches remote port #)
TInetAddress fAddress remote internet address and port #
See also
-
TServerSocket
TSocket
This class implements client sockets. A socket is an endpoint for
communication between two machines.
The actual work is done via the TSystem class (either TUnixSystem,
TWin32System or TMacSystem).
TSocket(TInetAddress addr, const char *service)
: TNamed(addr.GetHostName(), service)
Create a socket. Connect to the named service at address addr.
Returns when connection has been accepted by remote side. Use IsValid()
to check the validity of the socket. Every socket is added to the TROOT
sockets list which will make sure that any open sockets are properly
closed on program termination.
TSocket(TInetAddress addr, Int_t port)
: TNamed(addr.GetHostName(), "")
Create a socket. Connect to the specified port # at address addr.
Returns when connection has been accepted by remote side. Use IsValid()
to check the validity of the socket. Every socket is added to the TROOT
sockets list which will make sure that any open sockets are properly
closed on program termination.
TSocket(const char *host, const char *service)
: TNamed(host, service)
Create a socket. Connect to named service on the remote host.
Returns when connection has been accepted by remote side. Use IsValid()
to check the validity of the socket. Every socket is added to the TROOT
sockets list which will make sure that any open sockets are properly
closed on program termination.
TSocket(const char *host, Int_t port)
: TNamed(host, "")
Create a socket. Connect to specified port # on the remote host.
Returns when connection has been accepted by remote side. Use IsValid()
to check the validity of the socket. Every socket is added to the TROOT
sockets list which will make sure that any open sockets are properly
closed on program termination.
TSocket(Int_t desc) : TNamed("", "")
Create a socket. The socket will use descriptor desc.
TSocket(const TSocket &s)
TSocket copy ctor.
void Close(Option_t *)
Close the socket. Also called via the dtor.
TInetAddress GetLocalInetAddress()
Return internet address of local host to which the socket is bound.
In case of error TInetAddress::IsValid() returns kFALSE.
Int_t GetLocalPort()
Return the local port # to which the socket is bound.
In case of error return -1.
Int_t Send(Int_t kind)
Send a single message opcode. Use kind (opcode) to set the
TMessage "what" field. Returns the number of bytes that were sent
(always sizeof(Int_t)) and -1 in case of error. In case the kind has
been or'ed with kMESS_ACK, the call will only return after having
received an acknowledgement, making the sending process synchronous.
Int_t Send(const char *str, Int_t kind)
Send a character string buffer. Use kind to set the TMessage "what" field.
Returns the number of bytes in the string str that were sent and -1 in
case of error. In case the kind has been or'ed with kMESS_ACK, the call
will only return after having received an acknowledgement, making the
sending process synchronous.
Int_t Send(const TMessage &mess)
Send a TMessage object. Returns the number of bytes in the TMessage
that were sent and -1 in case of error. In case the TMessage::What
has been or'ed with kMESS_ACK, the call will only return after having
received an acknowledgement, making the sending process synchronous.
Int_t SendObject(const TObject *obj, Int_t kind)
Send an object. Returns the number of bytes sent and -1 in case of error.
In case the "kind" has been or'ed with kMESS_ACK, the call will only
return after having received an acknowledgement, making the sending
synchronous.
Int_t SendRaw(const void *buffer, Int_t length, ESendRecvOptions opt)
Send a raw buffer of specified length. Using option kOob one can send
OOB data. Returns the number of bytes sent or -1 in case of error.
Int_t Recv(char *str, Int_t max)
Receive a character string message of maximum max length. The expected
message must be of type kMESS_STRING. Returns length of received string
(can be 0 if otherside of connection is closed) or -1 in case of error
or -4 in case a non-blocking socket would block (i.e. there is nothing
to be read).
Int_t Recv(char *str, Int_t max, Int_t &kind)
Receive a character string message of maximum max length. Returns in
kind the message type. Returns length of received string (can be 0 if
other side of connection is closed) or -1 in case of error or -4 in
case a non-blocking socket would block (i.e. there is nothing to be read).
Int_t Recv(TMessage *&mess)
Receive a TMessage object. The user must delete the TMessage object.
Returns length of message in bytes (can be 0 if other side of connection
is closed) or -1 in case of error or -4 in case a non-blocking socket would
block (i.e. there is nothing to be read). In those case mess == 0.
Int_t RecvRaw(void *buffer, Int_t length, ESendRecvOptions opt)
Receive a raw buffer of specified length bytes. Using option kPeek
one can peek at incoming data. Returns -1 in case of error. In case
of opt == kOob: -2 means EWOULDBLOCK and -3 EINVAL. In case of non-blocking
mode (kNoBlock) -4 means EWOULDBLOCK.
Int_t SetOption(ESockOptions opt, Int_t val)
Set socket options.
Int_t GetOption(ESockOptions opt, Int_t &val)
Get socket options. Returns -1 in case of error.
Int_t GetErrorCode() const
Returns error code. Meaning depends on context where it is called.
If no error condition returns 0 else a value < 0.
For example see TServerSocket ctor.
Inline Functions
void operator=(const TSocket&)
void SetDescriptor(Int_t desc)
TSocket TSocket(const TSocket& s)
Int_t GetDescriptor() const
TInetAddress GetInetAddress() const
Int_t GetPort() const
UInt_t GetBytesSent() const
UInt_t GetBytesRecv() const
Bool_t IsValid() const
Int_t GetOption(ESockOptions opt, Int_t& val)
UInt_t GetSocketBytesSent()
UInt_t GetSocketBytesRecv()
TClass* Class()
TClass* IsA() const
void ShowMembers(TMemberInspector& insp, char* parent)
void Streamer(TBuffer& b)
void ~TSocket()
Author: Fons Rademakers 18/12/96
Last update: 2.21/01 14/01/99 13.34.42 by Fons Rademakers
Copyright (c) 1995-1999, The ROOT System, All rights reserved. *
ROOT page - Class index - Top of the page
This page has been automatically generated. If you have any comments or suggestions about the page layout send a mail to ROOT support, or contact the developers with any questions or problems regarding ROOT.