38 if (ActCvServer::singleInstance !=
nullptr) {
40 ActCvServer::singleInstance=
nullptr;
71 if (ActCvServer::singleInstance !=
nullptr) {
73 ActCvServer::singleInstance=
nullptr;
93 struct sockaddr_in srv;
94 if((
fd = socket(AF_INET, SOCK_STREAM, 0)) < 0) {
100 int result = setsockopt(
fd,
107 cerr <<
"error " << WSAGetLastError() << endl;
108 perror(
"setsockopt");
112 srv.sin_family = AF_INET;
113 srv.sin_port = htons(portNum);
116 srv.sin_addr.s_addr = htonl(INADDR_ANY);
117 if(::bind(
fd, (
struct sockaddr*) &srv,
sizeof(srv)) < 0) {
122 if(listen(
fd, 5) < 0) {
126 printf (
"Server wartet auf Verbindungen\n");
132 struct sockaddr_in client;
133 int client_len =
sizeof(client);
135 conn = accept(
fd, (
struct sockaddr*) &client, &client_len);
145 if (&*
data ==
nullptr) {
147 if (send(handle, (
const char*)&numBytes,
sizeof(numBytes), 0) < 0) {
154 if (send(handle, (
const char*)&numBytes,
sizeof(numBytes), 0) < 0) {
183 cerr << e.what() << endl;
192 if (recv(newfd, &c, 1, 0)<1)
break;
198 if (recv(newfd, (
char*)&keyCode,
sizeof(
int), 0)<1)
break;
203 cerr <<
"server received unknown message" << endl;
206 cerr << e.what() << endl;
217 struct WSAAutoStart {
218 WORD wVersionRequested;
223 wVersionRequested = MAKEWORD( 2, 2 );
225 WSAStartup(wVersionRequested, &wsaData);
232 #endif // def _WINDOWS