SDK Socket API documentation

Version: alpha

FUNCTION
INVALID_SOCKET_HANDLE()
SOCKET_TIMEOUT()
dmSocket::Connect()

make a connection

dmSocket::Delete()

delete a socket

dmSocket::GetFD()

get underlying file descriptor

dmSocket::GetHostByName()

get host by name

dmSocket::New()

create a socket

dmSocket::Receive()

Receive data on a socket

dmSocket::ResultToString()

Convert result value to string

dmSocket::Select()
dmSocket::SelectorClear()
dmSocket::SelectorIsSet()
dmSocket::SelectorSet()
dmSocket::SelectorZero()
dmSocket::Send()

Send a message on a socket

dmSocket::SetBlocking()
dmSocket::SetBroadcast()
dmSocket::SetNoDelay()
dmSocket::SetQuickAck()
dmSocket::SetReceiveTimeout()
dmSocket::SetReuseAddress()
dmSocket::SetSendTimeout()
dmSocket::Shutdown()

close socket

ENUMS
dmSocket::Domain

domain type

dmSocket::Protocol

network protocol

dmSocket::Result

socket result

dmSocket::SelectorKind
dmSocket::ShutdownType

socket shutdown type

dmSocket::Type

socket type

Functions

INVALID_SOCKET_HANDLE()

INVALID_SOCKET_HANDLE()

Invalid socket handle

PARAMETERS


SOCKET_TIMEOUT()

SOCKET_TIMEOUT()

Socket default timeout value

PARAMETERS


dmSocket::Connect()

dmSocket::Connect(socket,address,port)

Initiate a connection on a socket

PARAMETERS

socket

dmSocket::Socket Socket to initiate connection on

address

dmSocket::Address Address to connect to

port

int Port to connect to

RETURNS

RESULT_OK

on success


dmSocket::Delete()

dmSocket::Delete(socket)

Delete a socket. Corresponds to BSD socket function close()

PARAMETERS

socket

dmSocket::Socket Socket to close

RETURNS

RESULT_OK

on success


dmSocket::GetFD()

dmSocket::GetFD(socket)

Get underlying file descriptor

PARAMETERS

socket

dmSocket::Socket socket to get fd for

RETURNS

file-descriptor

dmSocket::GetHostByName()

dmSocket::GetHostByName(name,address,ipv4,ipv6)

Get host by name

PARAMETERS

name

const char* Hostname to resolve

address

dmSocket::Address* Host address result

ipv4

bool Whether or not to search for IPv4 addresses

ipv6

bool Whether or not to search for IPv6 addresses

RETURNS

RESULT_OK

on success


dmSocket::New()

dmSocket::New(type,protocol,socket)

Create a new socket. Corresponds to BSD socket function socket().

PARAMETERS

type

dmSocket::Type Socket type

protocol

dmSocket::Protocol Protocol

socket

dmSocket::Socket* Pointer to socket

RETURNS

RESULT_OK

on succcess


dmSocket::Receive()

dmSocket::Receive(socket,buffer[out],length,received_bytes[out])

PARAMETERS

socket

dmSocket::Socket Socket to receive data on

buffer[out]

void* Buffer to receive to

length

int Receive buffer length

received_bytes[out]

int* Number of received bytes (result)

RETURNS

RESULT_OK

on success


dmSocket::ResultToString()

dmSocket::ResultToString(result)

PARAMETERS

result

dmSocket::Result Result to convert

RETURNS

Result

as string


dmSocket::Select()

dmSocket::Select(selector,timeout)

Select for pending data

PARAMETERS

selector

Selector

timeout

Timeout. For blocking pass -1. (microseconds)

RETURNS

RESULT_OK

on success


dmSocket::SelectorClear()

dmSocket::SelectorClear(selector,selector_kind,socket)

Clear selector for socket. Similar to FD_CLR

PARAMETERS

selector

Selector

selector_kind

Kind to clear

socket

Socket to clear


dmSocket::SelectorIsSet()

dmSocket::SelectorIsSet(selector,selector_kind,socket)

Check if selector is set. Similar to FD_ISSET

PARAMETERS

selector

Selector

selector_kind

Selector kind

socket

Socket to check for

RETURNS

True

if set.


dmSocket::SelectorSet()

dmSocket::SelectorSet(selector,selector_kind,socket)

Set selector for socket. Similar to FD_SET

PARAMETERS

selector

Selector

selector_kind

Kind to clear

socket

Socket to set


dmSocket::SelectorZero()

dmSocket::SelectorZero(selector)

Clear selector (all kinds). Similar to FD_ZERO

PARAMETERS

selector

Selector


dmSocket::Send()

dmSocket::Send(socket,buffer,length,sent_bytes[out])

PARAMETERS

socket

dmSocket::Socket Socket to send a message on

buffer

void* Buffer to send

length

int Length of buffer to send

sent_bytes[out]

int* Number of bytes sent (result)

RETURNS

RESULT_OK

on success


dmSocket::SetBlocking()

dmSocket::SetBlocking(socket,blocking)

Set blocking option on a socket

PARAMETERS

socket

dmSocket::Socket Socket to set blocking on

blocking

bool True to block

RETURNS

RESULT_OK

on success


dmSocket::SetBroadcast()

dmSocket::SetBroadcast(socket,broadcast)

Set broadcast address option on socket. Socket option SO_BROADCAST on most platforms.

PARAMETERS

socket

dmSocket::Socket Socket to set reuse address to

broadcast

bool True if broadcast

RETURNS

RESULT_OK

on success


dmSocket::SetNoDelay()

dmSocket::SetNoDelay(socket,no_delay)

Set TCP_NODELAY on socket

PARAMETERS

socket

dmSocket::Socket Socket to set TCP_NODELAY on

no_delay

bool True for no delay

RETURNS

RESULT_OK

on success


dmSocket::SetQuickAck()

dmSocket::SetQuickAck(socket,use_quick_ack)

Set TCP_QUICKACK on socket

PARAMETERS

socket

dmSocket::Socket Socket to set TCP_QUICKACK on

use_quick_ack

bool False to disable quick ack

RETURNS

RESULT_OK

on success


dmSocket::SetReceiveTimeout()

dmSocket::SetReceiveTimeout(socket,timeout)

Set socket receive timeout

PARAMETERS

socket

dmSocket::Socket socket

timeout

uint64_t timeout in microseconds

RETURNS

RESULT_OK

on success


dmSocket::SetReuseAddress()

dmSocket::SetReuseAddress(socket,reuse)

Set reuse socket address option on socket. Socket option SO_REUSEADDR on most platforms

PARAMETERS

socket

dmSocket::Socket Socket to set reuse address to

reuse

bool True if reuse

RETURNS

RESULT_OK

on success


dmSocket::SetSendTimeout()

dmSocket::SetSendTimeout(socket,timeout)

Set socket send timeout

PARAMETERS

socket

dmSocket::Socket socket

timeout

uint64_t timeout in microseconds

RETURNS

RESULT_OK

on success


dmSocket::Shutdown()

dmSocket::Shutdown(socket,how)

Shutdown part of a socket connection

PARAMETERS

socket

dmSocket::Socket Socket to shutdown connection ow

how

dmSocket::ShutdownType Shutdown type

RETURNS

RESULT_OK

on success


Enums

dmSocket::Domain

domain type

Domain type

dmSocket::DOMAIN_MISSING
dmSocket::DOMAIN_IPV4
dmSocket::DOMAIN_IPV6
dmSocket::DOMAIN_UNKNOWN

dmSocket::Protocol

network protocol

Network protocol

dmSocket::PROTOCOL_TCP
dmSocket::PROTOCOL_UDP

dmSocket::Result

socket result

Socket result

dmSocket::RESULT_OK

0

dmSocket::RESULT_ACCES

-1

dmSocket::RESULT_AFNOSUPPORT

-2

dmSocket::RESULT_WOULDBLOCK

-3

dmSocket::RESULT_BADF

-4

dmSocket::RESULT_CONNRESET

-5

dmSocket::RESULT_DESTADDRREQ

-6

dmSocket::RESULT_FAULT

-7

dmSocket::RESULT_HOSTUNREACH

-8

dmSocket::RESULT_INTR

-9

dmSocket::RESULT_INVAL

-10

dmSocket::RESULT_ISCONN

-11

dmSocket::RESULT_MFILE

-12

dmSocket::RESULT_MSGSIZE

-13

dmSocket::RESULT_NETDOWN

-14

dmSocket::RESULT_NETUNREACH

-15

dmSocket::RESULT_NOBUFS

-17

dmSocket::RESULT_NOTCONN

-20

dmSocket::RESULT_NOTSOCK

-22

dmSocket::RESULT_OPNOTSUPP

-23

dmSocket::RESULT_PIPE

-24

dmSocket::RESULT_PROTONOSUPPORT

-25

dmSocket::RESULT_PROTOTYPE

-26

dmSocket::RESULT_TIMEDOUT

-27

dmSocket::RESULT_ADDRNOTAVAIL

-28

dmSocket::RESULT_CONNREFUSED

-29

dmSocket::RESULT_ADDRINUSE

-30

dmSocket::RESULT_CONNABORTED

-31

dmSocket::RESULT_INPROGRESS

-32

dmSocket::RESULT_HOST_NOT_FOUND

-100

dmSocket::RESULT_TRY_AGAIN

-101

dmSocket::RESULT_NO_RECOVERY

-102

dmSocket::RESULT_NO_DATA

-103

dmSocket::RESULT_UNKNOWN

-1000


dmSocket::SelectorKind

Selector kind

dmSocket::SELECTOR_KIND_READ
dmSocket::SELECTOR_KIND_WRITE
dmSocket::SELECTOR_KIND_EXCEPT

dmSocket::ShutdownType

socket shutdown type

Socket shutdown type

dmSocket::SHUTDOWNTYPE_READ
dmSocket::SHUTDOWNTYPE_WRITE
dmSocket::SHUTDOWNTYPE_READWRITE

dmSocket::Type

socket type

Socket type

dmSocket::TYPE_STREAM
dmSocket::TYPE_DGRAM