MCPcopy Create free account
hub / github.com/cuberite/cuberite / Init

Method Init

Tools/ProtoProxy/Server.cpp:22–52  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

20
21
22int cServer::Init(short a_ListenPort, short a_ConnectPort)
23{
24 m_ConnectPort = a_ConnectPort;
25
26 #ifdef _WIN32
27 WSAData wsa;
28 int res = WSAStartup(0x0202, &wsa);
29 if (res != 0)
30 {
31 printf("Cannot initialize WinSock: %d\n", res);
32 return res;
33 }
34 #endif // _WIN32
35
36 printf("Generating protocol encryption keypair...\n");
37 m_PrivateKey.Generate();
38 m_PublicKeyDER = m_PrivateKey.GetPubKeyDER();
39
40 m_ListenSocket = socket(AF_INET, SOCK_STREAM, IPPROTO_TCP);
41 sockaddr_in local;
42 memset(&local, 0, sizeof(local));
43 local.sin_family = AF_INET;
44 local.sin_addr.s_addr = 0; // All interfaces
45 local.sin_port = htons(a_ListenPort);
46 bind(m_ListenSocket, (sockaddr *)&local, sizeof(local));
47 listen(m_ListenSocket, 1);
48
49 printf("Listening on port %d, connecting to localhost:%d\n", a_ListenPort, a_ConnectPort);
50
51 return 0;
52}
53
54
55

Callers 2

mainFunction · 0.45

Calls 2

GetPubKeyDERMethod · 0.80
GenerateMethod · 0.45

Tested by

no test coverage detected