Initial commit

This commit is contained in:
Cameron Gutman
2014-01-18 15:14:42 -05:00
commit f02e916f6c
11 changed files with 475 additions and 0 deletions

View File

@@ -0,0 +1,22 @@
#include "PlatformSockets.h"
SOCKET connectTcpSocket(IP_ADDRESS dstaddr, unsigned short port) {
SOCKET s;
struct sockaddr_in addr;
s = socket(AF_INET, SOCK_STREAM, IPPROTO_TCP);
if (s == INVALID_SOCKET) {
return INVALID_SOCKET;
}
memset(&addr, 0, sizeof(addr));
addr.sin_family = AF_INET;
addr.sin_port = htons(port);
memcpy(&addr.sin_addr, &dstaddr, sizeof(dstaddr));
if (connect(s, (struct sockaddr*) &addr, sizeof(addr)) == SOCKET_ERROR) {
closesocket(s);
return INVALID_SOCKET;
}
return s;
}