34 #ifndef PTLIB_SOCKET_H 35 #define PTLIB_SOCKET_H 43 #ifdef __NUCLEUS_PLUS__ 44 #include <sys/socket.h> 103 unsigned queueSize = 5,
155 int level = SOL_SOCKET
166 const void * valuePtr,
168 int level = SOL_SOCKET
180 int level = SOL_SOCKET
193 int level = SOL_SOCKET
240 const char * protocol,
266 const char * protocol,
316 { DisallowDeleteObjects(); }
393 inline static WORD
Host2Net(WORD v) {
return htons(v); }
396 inline static DWORD
Host2Net(DWORD v) {
return htonl(v); }
399 inline static WORD
Net2Host(WORD v) {
return ntohs(v); }
401 inline static DWORD
Net2Host(DWORD v) {
return ntohl(v); }
416 int os_socket(
int af,
int type,
int proto);
418 struct sockaddr * sin,
425 struct sockaddr * from,
432 struct sockaddr * to,
437 struct sockaddr * addr,
448 virtual void SetLastReceiveAddr(
void * ,
int )
454 #include "msos/ptlib/socket.h" 456 #include "unix/ptlib/socket.h" 480 return FD_ISSET(fd,
set);
483 operator fd_set*()
const 520 return infinite ? NULL : &tval;
539 class PWinSock :
public PSocket 553 #endif // PTLIB_SOCKET_H
P_timeval(const PTimeInterval &time)
Definition: socket.h:511
static DWORD Host2Net(DWORD v)
Convert from host to network byte order.
Definition: socket.h:396
This class defines an arbitrary time interval to millisecond accuracy.
Definition: timeint.h:55
PString GetService() const
Get a service name for the port number the TCP socket channel object instance is using.
#define PCLASSINFO(cls, par)
Declare all the standard PTLib class information.
Definition: object.h:1049
PLIST(PSocketList, PSocket)
PChannel & operator=(const PChannel &)
PBoolean os_connect(struct sockaddr *sin, PINDEX size)
static WORD GetProtocolByName(const PString &name)
Get the number of the protocol associated with the specified name.
static int Select(PSocket &sock1, PSocket &sock2)
Select a socket with available data.
List of sockets used for Select() function.
Definition: socket.h:311
virtual PBoolean Shutdown(ShutdownValue option)
Close one or both of the data streams associated with a socket.
WORD port
Port to be used by the socket when opening the channel.
Definition: socket.h:444
ShutdownValue
Definition: channel.h:433
static PString GetNameByProtocol(WORD proto)
Get the name of the protocol number specified.
Errors
Normalised error codes.
Definition: channel.h:529
virtual PBoolean Connect(const PString &address)
Connect a socket to a remote host on the specified port number.
timeval * operator->()
Definition: socket.h:523
BOOL PBoolean
Definition: object.h:102
static DWORD Net2Host(DWORD v)
Convert from network to host byte order.
Definition: socket.h:401
PBoolean GetOption(int option, int &value, int level=SOL_SOCKET)
Get options on the socket.
PBoolean os_accept(PSocket &listener, struct sockaddr *addr, PINDEX *size)
#define free(p)
Override of system call for memory check system.
Definition: object.h:864
virtual PBoolean OpenSocket()=0
virtual WORD GetPortByService(const PString &service) const
Get the port number for the specified service name.
static WORD Host2Net(WORD v)
Convert from host to network byte order.
Definition: socket.h:394
Abstract class defining I/O channel semantics.
Definition: channel.h:107
The character string class.
Definition: pstring.h:108
SOCKET max_fd
Definition: socket.h:491
virtual PString GetServiceByPort(WORD port) const
Get the service name from the port number.
PBoolean os_recvfrom(void *buf, PINDEX len, int flags, struct sockaddr *from, PINDEX *fromlen)
WORD GetPort() const
Get the port the TCP socket channel object instance is using.
void operator-=(PSocket &sock)
Remove a socket from list .
Definition: socket.h:321
void operator+=(PSocket &sock)
Add a socket to list .
Definition: socket.h:318
~P_fd_set()
Definition: socket.h:467
virtual const char * GetProtocolName() const =0
This function returns the protocol name for the socket type.
A network communications channel.
Definition: socket.h:58
static WORD Net2Host(WORD v)
Convert from network to host byte order.
Definition: socket.h:399
Reusability
Flags to reuse of port numbers in Listen() function.
Definition: socket.h:84
PBoolean SetOption(int option, int value, int level=SOL_SOCKET)
Set options on the socket.
PBoolean IsPresent(SOCKET fd) const
Definition: socket.h:478
virtual PBoolean Listen(unsigned queueSize=5, WORD port=0, Reusability reuse=AddressIsExclusive)
Listen on a socket for a remote host on the specified port number.
virtual PBoolean Accept(PSocket &socket)
Open a socket to a remote host on the specified port number.
void SetPort(WORD port)
Set the port number for the channel.
int os_socket(int af, int type, int proto)
timeval & operator*()
Definition: socket.h:528
PBoolean os_sendto(const void *buf, PINDEX len, int flags, struct sockaddr *to, PINDEX tolen)