blob: 9e36925d40913def3d77306ddfc4d7ebb93d408d (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
|
#include <sys/types.h>
#include <sys/socket.h>
#include <netinet/in.h>
#include <errno.h>
#include "socket.h"
#include "byte.h"
int socket_bind(int fd,const unsigned char *ip,const unsigned char *port)
{
struct sockaddr_in sa;
byte_zero(&sa,sizeof sa);
byte_copy(&sa.sin_addr,4,ip);
byte_copy(&sa.sin_port,2,port);
return bind(fd,(struct sockaddr *) &sa,sizeof sa);
}
|