Public Member Functions |
| | Socket (socket_t *) |
| | Socket (const char *hostAddr, int port) |
| virtual | ~Socket () |
| int | readdata (void *buf, int bufsz) |
| | returns nrbytes read
|
| bool | writedata (void const *buf, int nrbytes) |
| bool | read (BufferString &) |
| bool | read (IOPar &) |
| bool | read (SeparString &) |
| bool | read (int &) |
| bool | read (bool &) |
| bool | read (BufferStringSet &) |
| bool | write (const char *) |
| bool | write (const BufferStringSet &) |
| bool | write (const BufferString &) |
| bool | write (const IOPar &) |
| bool | write (const SeparString &) |
| bool | write (int) |
| bool | write (bool) |
| bool | readtag (char &) |
| bool | readtag (char &, BufferString &) |
| bool | readtag (char &, SeparString &) |
| bool | readtag (char &, bool &) |
| bool | readtag (char &, int &) |
| bool | readtag2 (char &, int &, int &) |
| bool | writetag (char) |
| bool | writetag (char, const char *) |
| bool | writetag (char, const BufferString &) |
| bool | writetag (char, const SeparString &) |
| bool | writetag (char, const IOPar &) |
| bool | writetag (char, int) |
| bool | writetag (char, int, int) |
| bool | writetag (char, bool) |
| bool | readtags (char &, char &) |
| bool | readtags (char &, char &, BufferString &) |
| bool | readtags (char &, char &, bool &) |
| bool | readtags (char &, char &, int &) |
| bool | writetags (char, char) |
| bool | writetags (char, char, const char *) |
| bool | writetags (char, char, const BufferString &) |
| bool | writetags (char, char, const IOPar &) |
| bool | writetags (char, char, int) |
| bool | writetags (char, char, bool) |
| bool | ok () const |
| bool | writeErrorMsg (const char *) |
| const char * | peekMsg () const |
| void | fetchMsg (BufferString &) |
| int | timeOut () |
| void | setTimeOut (int t) |
Static Public Member Functions |
| static int | defaultTimout () |
| static void | setDefaultTimout (int t) |
Protected Member Functions |
| int | readbuf_ (void *buf, int bufsz, BufferString *bs=0) |
| | if buf==bs->buf(), bs->bufSize is incrsd if needed
|
| int | rawread_ (void *buf, int minbytes, int maxbytes) |
| bool | writebuf_ (const void *buf, int nrbytes) |
| bool | rawwrite_ (const void *buf, int nrbytes) |
Protected Attributes |
| int | time_out |
Private Attributes |
| socket_t * | sock_ |
Represents an end point of a TCP/IP connection.
A client program creates a socket that connects to a server at a given port.
Simultaneous reads and simultaneous writes are prohibited trough a mutex. It is possible to perform one read and one write simultaneously, though.
| bool Socket::writeErrorMsg |
( |
const char * |
|
) |
|
The Socket class supports error handling. You can write an error message to the socket, which is put in the error buffer of the peer.
Since there is no look-ahead, it is not possible to write an error message by itself, unless the receiving side is continuesly polling for data, like in the multithreaded IOHandler in "jobman.h".
In a normal communication protocol, you would transfer f.e. a boolean to signal failure or success anyway, so if you write the error message on the sending side just before transmitting fail/success, the message will be available on the receiving site at the moment the bool has been read.