2003-11-06 20:47:59 +00:00
|
|
|
#ifndef __MINGW32__
|
2001-10-15 14:34:02 +00:00
|
|
|
#include <sys/types.h>
|
2001-02-05 17:50:19 +00:00
|
|
|
#include <sys/socket.h>
|
|
|
|
#include <netinet/in.h>
|
2003-11-06 20:47:59 +00:00
|
|
|
#endif
|
|
|
|
#include "windoze.h"
|
2001-02-05 17:50:19 +00:00
|
|
|
#include "byte.h"
|
|
|
|
#include "uint16.h"
|
|
|
|
#include "uint32.h"
|
|
|
|
#include "socket.h"
|
|
|
|
|
2021-04-27 17:39:42 +00:00
|
|
|
int socket_bind4(int s,const char ip[4],uint16 port) {
|
2001-02-05 17:50:19 +00:00
|
|
|
struct sockaddr_in si;
|
|
|
|
byte_zero(&si,sizeof si);
|
|
|
|
si.sin_family = AF_INET;
|
|
|
|
uint16_pack_big((char*) &si.sin_port,port);
|
2003-05-27 19:00:44 +00:00
|
|
|
if (ip)
|
|
|
|
*(uint32*)&si.sin_addr = *(uint32*)ip;
|
|
|
|
else
|
|
|
|
si.sin_addr.s_addr=INADDR_ANY;
|
2003-11-06 20:47:59 +00:00
|
|
|
return winsock2errno(bind(s,(struct sockaddr*)&si,sizeof si));
|
2001-02-05 17:50:19 +00:00
|
|
|
}
|