http://www.kirstenfan.com/galleries/magazines/fhm2002100sexy/002.jpg -- studies show charming women love computer programmers......

This commit is contained in:
mpc
2004-07-03 11:05:23 +00:00
committed by zzz
parent 4b8ac81669
commit a13693161a
11 changed files with 517 additions and 27 deletions

View File

@@ -31,17 +31,57 @@
#include "platform.hpp"
#include "socket.hpp"
size_t Socket::total = 0; // the total number of sockets in use
/*
* Constructs an IPv4 TCP socket
*/
Socket::Socket(void)
{
++total;
#ifdef WINSOCK
if (total == 1)
winsock_startup();
#endif
socket(PF_INET, SOCK_STREAM);
}
/*
* Constructs a socket
*
* domain - either PF_INET or PF_INET6
* type - either SOCK_STREAM or SOCK_DGRAM
*/
Socket::Socket(int domain, int type)
{
++total;
#ifdef WINSOCK
if (total == 1)
winsock_startup();
#endif
socket(domain, type);
}
/*
* Destroys a socket
*/
Socket::~Socket(void)
{
total--;
// TODO: finish me
}
/*
* Creates a socket
*
* domain - either PF_INET or PF_INET6
* type - either SOCK_STREAM or SOCK_DGRAM
*/
Socket::Socket(int type)
void Socket::create_socket(int domain, int type)
{
#ifdef WINSOCK
winsock_startup();
#endif
sock = socket(PF_INET, type, 0);
assert((domain == PF_INET || domain == PF_INET6) &&
(type == SOCK_STREAM || type == SOCK_DGRAM));
sock = socket(domain, type, 0);
#ifdef WINSOCK
if (sock == INVALID_SOCKET)
throw Socket_error(sam_winsock_strerror(WSAGetLastError()));