-
Notifications
You must be signed in to change notification settings - Fork 0
/
SocketBase.cpp
40 lines (28 loc) · 963 Bytes
/
SocketBase.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
/*###############################
# FH Salzburg #
# WS2010 MMT-B2009 #
# Multimediale Netzwerke #
# Uebungsprojekt #
# Fritsch Andreas, Hanli Ismail #
# Sun, 28.11.2010 22:00 #
###############################*/
#include "SocketBase.h"
SocketBase::SocketBase(const WORD clientSocketVersion, const int type, const int protocol) :
version(clientSocketVersion), type(type), protocol(protocol) {}
void SocketBase::createSocket(SOCKET* base, int af)
{
WSADATA wsa;
int errorCode;
printf("\nStarting baseSocket...");
errorCode = WSAStartup(version, &wsa);
if(errorCode != 0)
throw "\nFAIL: Couldn't start baseSocket (WSAStartup)";
else
printf("\nSUCCESS: baseSocket started!");
printf("\nCreating clientSocket...");
*base = socket(af, type, protocol);
if(*base == INVALID_SOCKET)
throw "\nFAIL: Couldn't create socket (socket)";
else
printf("\nSUCCESS: Socket created!");
}