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