Socket Class Reference
#include <PracticalSocket.h>
List of all members.
Detailed Description
Socket super class
Constructor & Destructor Documentation
| Socket::Socket |
( |
const Socket & |
sock |
) |
[private] |
| Socket::Socket |
( |
int |
type, |
|
|
int |
protocol | |
|
) |
| | throw (SocketException) [protected] |
| Socket::Socket |
( |
int |
sockDesc |
) |
[protected] |
Member Function Documentation
Get the local address
- Returns:
- local address of socket
- Exceptions:
-
References sockDesc.
Get the local port
- Returns:
- local port of socket
- Exceptions:
-
References sockDesc.
| void Socket::setLocalPort |
( |
unsigned short |
localPort |
) |
throw (SocketException) |
Set the local port to the specified port and the local address to any interface
- Parameters:
-
- Exceptions:
-
| void Socket::setLocalAddressAndPort |
( |
const string & |
localAddress, |
|
|
unsigned short |
localPort = 0 | |
|
) |
| | throw (SocketException) |
Set the local port to the specified port and the local address to the specified address. If you omit the port, a random port will be selected.
- Parameters:
-
| localAddress | local address |
| localPort | local port |
- Exceptions:
-
References fillAddr().
If WinSock, unload the WinSock DLLs; otherwise do nothing. We ignore this in our sample client code but include it in the library for completeness. If you are running on Windows and you are concerned about DLL resource consumption, call this after you are done with all Socket instances. If you execute this on Windows while some instance of Socket exists, you are toast. For portability of client code, this is an empty function on non-Windows platforms so you can always include it.
- Parameters:
-
| buffer | buffer to receive the data |
| bufferLen | maximum number of bytes to read into buffer |
- Returns:
- number of bytes read, 0 for EOF, and -1 for error
- Exceptions:
-
| unsigned short Socket::resolveService |
( |
const string & |
service, |
|
|
const string & |
protocol = "tcp" | |
|
) |
| | [static] |
Resolve the specified service for the specified protocol to the corresponding port number in host byte order
- Parameters:
-
| service | service to resolve (e.g., "http") |
| protocol | protocol of service to resolve. Default is "tcp". |
| void Socket::operator= |
( |
const Socket & |
sock |
) |
[private] |
Member Data Documentation
Referenced by TCPServerSocket::accept(), UDPSocket::disconnect(), CommunicatingSocket::getForeignAddress(), CommunicatingSocket::getForeignPort(), getLocalAddress(), getLocalPort(), UDPSocket::joinGroup(), UDPSocket::leaveGroup(), UDPSocket::recvFrom(), UDPSocket::sendTo(), UDPSocket::setBroadcast(), UDPSocket::setMulticastTTL(), and ~Socket().
The documentation for this class was generated from the following files: