#include <JSocket.h>


Public Member Functions | |
| JSocket (JString addr, int portnumber, JString protocolname="") | |
| Constructor. | |
| JSocket (const TCPLocation &loc, JString protocolname="") | |
| Constructor. | |
| JSocket (SOCKET new_sock) | |
| Constructor. | |
| virtual | ~JSocket () |
| Object * | clone () const |
| bool | setUpListening () |
| Bind to port. | |
| JSocket * | waitForConnection (long timeout) |
| Wait for incoming connection. Returns NULL or a Socket*. | |
| bool | connectNow () |
| Tries to connect to remote Socket. | |
| bool | connectNow (const IPNumber &ip, int port) |
| Under the hood connectNow(). | |
| bool | disconnectNow () |
| Tries to disconnect from remote Socket, called by terminate. | |
| bool | terminate () |
| Terminates the local Socket, will auto disconnectNow. | |
| int | flush () |
| int | read (char *buffer, int maxcount, long timeout) |
| Read a number of bytes from socket. | |
| JString | readString (int count, long timeout) |
| Read a String from socket. | |
| JString | readln (long timeout) |
| Read a line (ending with <CR>) from socket. | |
| int | write (JString str) |
| Write a string to socket. | |
| int | write (char *ch, int len) |
| Write a string to socket. | |
| int | writeln (JString str) |
| Write a string and a <CR> to socket. | |
| void | setNonBlockingMode () |
| void | setBlockingMode () |
| JString | getLocalIPAddress () |
| Collection | getLocalIPAddresses () |
| Dictionary | getLocalInterfaceAddresses () |
| JString | getLocalHostname () |
| JString | getRemoteHostname () |
| JString | getRemoteIPAddress () |
| JString | getIPAddressFromName (JString name) |
| IPNumber | getIPNumberFromName (JString name) |
| JString | getHostnameFromIPAddress (JString ipaddr) |
| bool | isConnected (int timeout=0) |
| Is the Socket connected? | |
| bool | waitForReadability (int timeout) |
| Wait timeout ms for data availability... | |
| bool | waitForWriteability (int timeout) |
| Wait timeout ms for data to be written... | |
| bool | didConnectionGoThrough (int timeout) |
| Is the Socket connected? | |
| bool | isListening () |
| Is the Socket connected? | |
| bool | isLastErrorRecoverable () |
| Is last error recoverable? | |
| JString | getLastErrorMessage () |
| Get the last error message. | |
| int | getLastOSErrorNumber () |
| Get the last error number, OS specific. | |
| void | osCloseSocket (SOCKET thisSocket) |
| Close down the socket, OS specific. | |
| bool | isSocketValid () |
| bool | setSocketNotValid () |
| bool | createSocket () |
| void | dealWithSocketError (int wsaError, JString intro="") |
| int | peekIntoStream () |
| int | peekIntoStream (char *buffer, int maxcount) |
| int | readIntoBuffer () |
| int | readChar (char *ch) |
| int | writeString (JString text) |
| int | writeBuffer (char *buf, int length) |
| double | getSendProgress () |
| double | getReceiveProgress () |
| long | getSendBufferSize () |
| long | getReadBufferSize () |
| double * | getIOCounts () |
| bool | resetIOCounts () |
Static Public Member Functions | |
| static bool | isIPAddressPrivate (JString addr) |
Public Attributes | |
| TCPLocation | location |
| JString | address |
| JString | localhostName |
| int | port |
| JString | protocol |
| JString | lastErrorMessage |
| IPNumber | ipnumber |
| char | charBuffer [BUFFERSIZE+8] |
| int | charBufferCount |
| JString | stringBuffer |
| bool | connected |
| bool | lastErrorRecoverable |
| bool | listening |
| SOCKET | mySocket |
| int | currentUnsentBufferSize |
| int | currentSentBufferSize |
| int | currentUnreceivedBufferSize |
| int | currentReceivedBufferSize |
| double | ioCounts [2] |
| Collection | localIPAddresses |
| JString | localIPAddress |
| JMutex | mutex |
| bool | isTerminating |
A Socket is one end of a network connection, to have communication you need a Socket in each end, connected to each other.
When you create a Socket object you provide it with an address which can be blank, a port number and a protocol type. For a listener you need the address to be blank and then ask it to listen(). For a regular connection you say connect() and it will try to connect to a listener on the remote machine.
Definition at line 132 of file JSocket.h.
Constructor.
Takes three parameters
| addr | the ip address, ignored for listeners. | |
| portnumber | the ip port, always needed. | |
| protocolname | the protocol, default = tcp. |
Definition at line 69 of file JSocket.cpp.
| cmlabs::JSocket::JSocket | ( | const TCPLocation & | loc, | |
| JString | protocolname = "" | |||
| ) |
Constructor.
Takes one parameters
| loc | a TCPLocation |
Definition at line 97 of file JSocket.cpp.
| cmlabs::JSocket::JSocket | ( | SOCKET | new_sock | ) |
Constructor.
Takes one parameters
| new_sock | the OS socket to base this instance on. |
Definition at line 1069 of file JSocket.cpp.
| cmlabs::JSocket::~JSocket | ( | ) | [virtual] |
Definition at line 125 of file JSocket.cpp.
| bool cmlabs::JSocket::isIPAddressPrivate | ( | JString | addr | ) | [static] |
Definition at line 2003 of file JSocket.cpp.
| Object* cmlabs::JSocket::clone | ( | ) | const [virtual] |
| bool cmlabs::JSocket::setUpListening | ( | ) |
| JSocket * cmlabs::JSocket::waitForConnection | ( | long | timeout | ) |
Wait for incoming connection. Returns NULL or a Socket*.
Definition at line 1168 of file JSocket.cpp.
| bool cmlabs::JSocket::connectNow | ( | ) |
| bool cmlabs::JSocket::connectNow | ( | const IPNumber & | ip, | |
| int | port | |||
| ) |
| bool cmlabs::JSocket::disconnectNow | ( | ) |
Tries to disconnect from remote Socket, called by terminate.
Definition at line 1439 of file JSocket.cpp.
| bool cmlabs::JSocket::terminate | ( | ) |
| int cmlabs::JSocket::flush | ( | ) |
Definition at line 160 of file JSocket.cpp.
| int cmlabs::JSocket::read | ( | char * | buffer, | |
| int | maxcount, | |||
| long | timeout | |||
| ) |
Read a number of bytes from socket.
| buffer | is the char* buffer | |
| maxcount | max number of bytes to read. | |
| timeout | timeout in ms |
Definition at line 173 of file JSocket.cpp.
| JString cmlabs::JSocket::readString | ( | int | count, | |
| long | timeout | |||
| ) |
Read a String from socket.
| count | number of bytes to read - no less! | |
| timeout | timeout in ms to wait for count bytes |
Definition at line 256 of file JSocket.cpp.
| JString cmlabs::JSocket::readln | ( | long | timeout | ) |
Read a line (ending with <CR>) from socket.
| timeout | timeout in ms |
Definition at line 316 of file JSocket.cpp.
| int cmlabs::JSocket::write | ( | JString | str | ) |
Write a string to socket.
| str | string to write. |
Definition at line 383 of file JSocket.cpp.
| int cmlabs::JSocket::write | ( | char * | ch, | |
| int | len | |||
| ) |
Write a string to socket.
| ch | chars to write. | |
| len | number of chars to write |
Definition at line 387 of file JSocket.cpp.
| int cmlabs::JSocket::writeln | ( | JString | str | ) |
Write a string and a <CR> to socket.
| str | string to write. |
Definition at line 391 of file JSocket.cpp.
| void cmlabs::JSocket::setNonBlockingMode | ( | ) |
Definition at line 58 of file JSocket_Linux.cpp.
| void cmlabs::JSocket::setBlockingMode | ( | ) |
Definition at line 65 of file JSocket_Linux.cpp.
| JString cmlabs::JSocket::getLocalIPAddress | ( | ) |
Definition at line 402 of file JSocket.cpp.
| Collection cmlabs::JSocket::getLocalIPAddresses | ( | ) |
Definition at line 430 of file JSocket.cpp.
| Dictionary cmlabs::JSocket::getLocalInterfaceAddresses | ( | ) |
Definition at line 603 of file JSocket.cpp.
| JString cmlabs::JSocket::getLocalHostname | ( | ) |
Definition at line 726 of file JSocket.cpp.
| JString cmlabs::JSocket::getRemoteHostname | ( | ) |
Definition at line 1007 of file JSocket.cpp.
| JString cmlabs::JSocket::getRemoteIPAddress | ( | ) |
Definition at line 971 of file JSocket.cpp.
Definition at line 1355 of file JSocket.cpp.
Definition at line 1254 of file JSocket.cpp.
Definition at line 1012 of file JSocket.cpp.
| bool cmlabs::JSocket::isConnected | ( | int | timeout = 0 |
) |
| bool cmlabs::JSocket::waitForReadability | ( | int | timeout | ) |
| bool cmlabs::JSocket::waitForWriteability | ( | int | timeout | ) |
| bool cmlabs::JSocket::didConnectionGoThrough | ( | int | timeout | ) |
| bool cmlabs::JSocket::isListening | ( | ) |
| bool cmlabs::JSocket::isLastErrorRecoverable | ( | ) |
| JString cmlabs::JSocket::getLastErrorMessage | ( | ) |
| int cmlabs::JSocket::getLastOSErrorNumber | ( | ) |
| void cmlabs::JSocket::osCloseSocket | ( | SOCKET | thisSocket | ) |
| bool cmlabs::JSocket::isSocketValid | ( | ) |
Definition at line 45 of file JSocket_Linux.cpp.
| bool cmlabs::JSocket::setSocketNotValid | ( | ) |
Definition at line 52 of file JSocket_Linux.cpp.
| bool cmlabs::JSocket::createSocket | ( | ) |
Definition at line 72 of file JSocket_Linux.cpp.
| void cmlabs::JSocket::dealWithSocketError | ( | int | wsaError, | |
| JString | intro = "" | |||
| ) |
Definition at line 102 of file JSocket_Linux.cpp.
| int cmlabs::JSocket::peekIntoStream | ( | ) |
Definition at line 1488 of file JSocket.cpp.
| int cmlabs::JSocket::peekIntoStream | ( | char * | buffer, | |
| int | maxcount | |||
| ) |
Definition at line 1493 of file JSocket.cpp.
| int cmlabs::JSocket::readIntoBuffer | ( | ) |
Definition at line 1533 of file JSocket.cpp.
| int cmlabs::JSocket::readChar | ( | char * | ch | ) |
Definition at line 1449 of file JSocket.cpp.
| int cmlabs::JSocket::writeString | ( | JString | text | ) |
Definition at line 1597 of file JSocket.cpp.
| int cmlabs::JSocket::writeBuffer | ( | char * | buf, | |
| int | length | |||
| ) |
Definition at line 1601 of file JSocket.cpp.
| double cmlabs::JSocket::getSendProgress | ( | ) |
Definition at line 2032 of file JSocket.cpp.
| double cmlabs::JSocket::getReceiveProgress | ( | ) |
Definition at line 2021 of file JSocket.cpp.
| long cmlabs::JSocket::getSendBufferSize | ( | ) |
Definition at line 136 of file JSocket.cpp.
| long cmlabs::JSocket::getReadBufferSize | ( | ) |
Definition at line 139 of file JSocket.cpp.
| double * cmlabs::JSocket::getIOCounts | ( | ) |
Definition at line 2045 of file JSocket.cpp.
| bool cmlabs::JSocket::resetIOCounts | ( | ) |
Definition at line 2051 of file JSocket.cpp.
| char cmlabs::JSocket::charBuffer[BUFFERSIZE+8] |
| double cmlabs::JSocket::ioCounts[2] |
1.5.6