File: socket_bind.c

package info (click to toggle)
nacl 20110221-15
  • links: PTS, VCS
  • area: main
  • in suites: sid, trixie
  • size: 4,560 kB
  • sloc: asm: 19,669; ansic: 13,434; cpp: 1,125; sh: 933; makefile: 32
file content (16 lines) | stat: -rw-r--r-- 406 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
#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);
  sa.sin_family = PF_INET;
  byte_copy(&sa.sin_addr,4,ip);
  byte_copy(&sa.sin_port,2,port);
  return bind(fd,(struct sockaddr *) &sa,sizeof sa);
}