shithub: femtolisp

ref: 7da7a91bc8a0162bf0f21d298c1a356fc2cbce00
dir: /llt/socket.h/

View raw version
#ifndef __LLTSOCKET_H_
#define __LLTSOCKET_H_

#ifndef PLAN9
#include <netinet/in.h>
#include <netdb.h>
#include <sys/types.h>
#include <sys/socket.h>
#include <fcntl.h>
#endif

int open_tcp_port(short portno);
int open_any_tcp_port(short *portno);
int open_any_udp_port(short *portno);
int connect_to_host(char *hostname, short portno);
int connect_to_addr(struct sockaddr_in *host_addr);
int sendall(int sockfd, char *buffer, int bufLen, int flags);
int readall(int sockfd, char *buffer, int bufLen, int flags);
int addr_eq(struct sockaddr_in *a, struct sockaddr_in *b);
int socket_ready(int sock);
void closesocket(int fd);

#endif