MAOS
Multithreaded Adaptive Optics Simulator
|
Functions | |
int | socket_recv_timeout (int sock, double sec) |
int | socket_send_timeout (int sock, double sec) |
int | connect_port (const char *hostname, int port, int block, int nodelay) |
void | listen_port (uint16_t port, char *localpath, int(*respond)(int), double timeout_sec, void(*timeout_fun)(), int nodelay) |
int | socket_nopipe (int sock) |
int | socket_block (int sock, int block) |
int | bind_socket (int protocol, char *ip, uint16_t port) |
int | socket_port (int sock) |
in_addr_t | socket_peer (int sock) |
const char * | addr2name (in_addr_t s_addr) |
Routines to establish socket connection
int socket_recv_timeout | ( | int | sock, |
double | sec | ||
) |
Set recv timeout in seconds
int socket_send_timeout | ( | int | sock, |
double | sec | ||
) |
Set recv timeout in seconds
int connect_port | ( | const char * | hostname, |
int | port, | ||
int | block, | ||
int | nodelay | ||
) |
Connect to a host at port. If hostname already includes port after :, port is ignored. hostname may start with / to indicate a local UNIX port
hostname | The hostname can be just name or name:port. |
port | The port if hostname does not include it |
block | Do we block until connection is established |
nodelay | set TCP nodelay flag |
void listen_port | ( | uint16_t | port, |
char * | localpath, | ||
int(*)(int) | responder, | ||
double | timeout_sec, | ||
void(*)() | timeout_fun, | ||
int | nodelay | ||
) |
Open a port and listen to it. Calls respond(sock) to handle data. If timeout_fun is not NULL, it will be called when 1) connection is establed/handled, 2) every timeout_sec if timeout_sec>0. This function only return at error. if localpath is not null and start with /, open the local unix port also if localpath is not null and contains ip address, only bind to that ip address
int socket_block | ( | int | sock, |
int | block | ||
) |
Set socket to unblocking mode
int bind_socket | ( | int | protocol, |
char * | ip, | ||
uint16_t | port | ||
) |
make a server port and bind to localhost on all addresses. protocl is usually SOCK_DGRAM or SOCK_STREAM. ip is usually zero. if port is 0, will bind an assigned port
int socket_port | ( | int | sock | ) |
determine the socket port
in_addr_t socket_peer | ( | int | sock | ) |
determine the socket peer IP address
const char* addr2name | ( | in_addr_t | s_addr | ) |
convert in_addr_t to host name for print out