CUBRID Engine  latest
wintcp.c
Go to the documentation of this file.
1 /*
2  * Copyright 2008 Search Solution Corporation
3  * Copyright 2016 CUBRID Corporation
4  *
5  * Licensed under the Apache License, Version 2.0 (the "License");
6  * you may not use this file except in compliance with the License.
7  * You may obtain a copy of the License at
8  *
9  * http://www.apache.org/licenses/LICENSE-2.0
10  *
11  * Unless required by applicable law or agreed to in writing, software
12  * distributed under the License is distributed on an "AS IS" BASIS,
13  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14  * See the License for the specific language governing permissions and
15  * limitations under the License.
16  *
17  */
18 
19 
20 /*
21  * wintcp.c - Open a TCP connection for Windows
22  */
23 
24 #ident "$Id$"
25 
26 #include "config.h"
27 
28 #include <stdio.h>
29 #include <string.h>
30 #include <signal.h>
31 #include <sys/types.h>
32 #include <sys/timeb.h>
33 #include <winsock2.h>
34 #include <windows.h>
35 #include <ws2tcpip.h>
36 
37 #include "dbtype.h"
38 #ifdef SERVER_MODE
39 #include "connection_error.h"
40 #include "connection_sr.h"
41 #else /* SERVER_MODE */
42 #include "connection_cl.h"
43 #endif /* SERVER_MODE */
44 #include "error_manager.h"
45 #include "error_code.h"
46 #include "connection_globals.h"
47 #include "wintcp.h"
48 #include "porting.h"
49 #include "system_parameter.h"
50 #include "client_support.h"
51 
52 #define HOST_ID_ARRAY_SIZE 8
53 
54 static const int css_Tcp_max_connect_tries = 3;
55 static const int css_Maximum_server_count = 1000;
56 
57 /* containing the last WSA error */
59 static FARPROC old_hook = NULL;
60 static int max_socket_fds = _SYS_OPEN;
61 
62 static unsigned int wsa_Init_count = 0;
63 static unsigned int css_fd_error (SOCKET fd);
64 
65 #if defined (ENABLE_UNUSED_FUNCTION)
66 /*
67  * css_get_wsa_error() - return the last WSA error
68  * return: the last WSA error
69  *
70  * Note: Must be exported so its visible through the DLL.
71  */
72 int
73 css_get_wsa_error (void)
74 {
75  return css_Wsa_error;
76 }
77 #endif /* ENABLE_UNUSED_FUNCTION */
78 
79 /*
80  * css_windows_blocking_hook() - blocking hook function
81  * return:
82  */
83 bool
85 {
86  return false;
87 }
88 
89 /*
90  * css_windows_startup() -
91  * return:
92  */
93 int
95 {
96  WORD wVersionRequested;
97  WSADATA wsaData;
98  int err;
99 
100  old_hook = NULL;
102  wVersionRequested = 0x101;
103  err = WSAStartup (wVersionRequested, &wsaData);
104  if (err != 0)
105  {
106  /* don't use WSAGetLastError since it has not been initialized. */
109  return -1;
110  }
111 
112  max_socket_fds = wsaData.iMaxSockets;
113 
114 #if 0
115  /*
116  * Establish a blocking "hook" function to prevent Windows messages
117  * from being dispatched when we block on reads.
118  */
119  old_hook = WSASetBlockingHook ((FARPROC) css_windows_blocking_hook);
120  if (old_hook == NULL)
121  {
122  /* couldn't set up our hook */
125  (void) WSACleanup ();
126  return -1;
127  }
128 #endif
129 
130  wsa_Init_count++;
131 
132  return 1;
133 }
134 
135 /*
136  * css_windows_shutdown() -
137  * return:
138  */
139 void
141 {
142  int err;
143 
144 #if 0
145  if (old_hook != NULL)
146  {
147  (void) WSASetBlockingHook (old_hook);
148  }
149 #endif
150  if (wsa_Init_count > 0)
151  {
152  err = WSACleanup ();
153  wsa_Init_count--;
154  }
155 }
156 
157 /*
158  * css_tcp_client_open() -
159  * return:
160  * hostname(in):
161  * port(in):
162  */
163 SOCKET
164 css_tcp_client_open (const char *host_name, int port)
165 {
166  SOCKET fd;
167 
168  fd = css_tcp_client_open_with_retry (host_name, port, true);
169  if (IS_INVALID_SOCKET (fd))
170  {
172  }
173  return fd;
174 }
175 
176 /*
177  * css_tcp_client_open_with_retry() -
178  * return:
179  * hostname(in):
180  * port(in):
181  * willretry(in):
182  */
183 SOCKET
184 css_tcp_client_open_with_retry (const char *host_name, int port, bool will_retry)
185 {
186  int bool_value;
187  SOCKET s;
188  int err;
189  struct hostent *dest_host;
190  unsigned int remote_ip;
191  struct sockaddr_in addr;
192  int success, numtries;
193 
194  /* Winsock must have been opened by now */
195 
196  /* first try the internet address format */
197  remote_ip = inet_addr (host_name);
198  if (remote_ip == INADDR_NONE)
199  {
200  /* then try a host name */
201  dest_host = gethostbyname (host_name);
202  if (dest_host == NULL)
203  {
205  return INVALID_SOCKET;
206  }
207  remote_ip = *((unsigned int *) (dest_host->h_addr));
208  }
209 
210  success = 0;
211  if (will_retry)
212  {
213  numtries = 0;
214  }
215  else
216  {
217  numtries = css_Tcp_max_connect_tries - 1;
218  }
219 
220  while (!success && numtries < css_Tcp_max_connect_tries)
221  {
222  s = socket (PF_INET, SOCK_STREAM, IPPROTO_TCP);
223  if (IS_INVALID_SOCKET (s))
224  {
226  return INVALID_SOCKET;
227  }
228 
229  addr.sin_family = AF_INET;
230  addr.sin_port = htons (port);
231  addr.sin_addr.s_addr = remote_ip;
232 
233  /*
234  * The master deliberately tries to connect to itself once to
235  * prevent multiple masters from running. In the "good" case,
236  * the connect will fail. Printing the message when that happens
237  * makes starting the master on NT disturbing because the users sees
238  * what they think is a bad message so don't print anything here.
239  */
240  if (connect (s, (struct sockaddr *) &addr, sizeof (addr)) != SOCKET_ERROR)
241  {
242  success = 1;
243  }
244  else
245  {
246  err = WSAGetLastError ();
247  (void) closesocket (s);
248 
249  if (err != WSAECONNREFUSED && err != WSAETIMEDOUT)
250  {
251  /* this isn't an error we handle */
252  return INVALID_SOCKET;
253  }
254  else
255  {
256  /*
257  * See tcp.c for Unix platforms for more information.
258  * retry the connection a few times in case the server is
259  * overloaded at the moment.
260  * Should be sleeping here but I can't find a Windows SDK function
261  * to do that.
262  */
263  numtries++;
264  }
265  }
266  }
267 
268  if (!success)
269  {
270  return INVALID_SOCKET;
271  }
272 
273  bool_value = 1;
274  /* ask for the "keep alive" option, ignore errors */
276  {
277  (void) setsockopt (s, SOL_SOCKET, SO_KEEPALIVE, (const char *) &bool_value, sizeof (int));
278  }
279 
280  /* ask for NODELAY, this one is rather important */
281  (void) setsockopt (s, IPPROTO_TCP, TCP_NODELAY, (const char *) &bool_value, sizeof (int));
282 
283  return s;
284 }
285 
286 /*
287  * css_shutdown_socket() -
288  * return:
289  * fd(in):
290  */
291 void
293 {
294  if (!IS_INVALID_SOCKET (fd))
295  {
296  closesocket (fd);
297  }
298 }
299 
300 /*
301  * css_fd_error() - Determine if a socket has any queued data
302  * return:
303  * fd(in):
304  */
305 static unsigned int
307 {
308  unsigned long count;
309  long rc;
310 
311  rc = ioctlsocket (fd, FIONREAD, &count);
312  if (rc == SOCKET_ERROR)
313  {
314  count = -1;
315  }
316 
317  return (count);
318 }
319 
320 #if defined (ENABLE_UNUSED_FUNCTION)
321 /*
322  * css_fd_down() - Determine if a socket has been shut down for some reason
323  * return:
324  * fd(in):
325  */
326 int
327 css_fd_down (SOCKET fd)
328 {
329  int error_code = 0;
330  int error_size = sizeof (int);
331 
332  if (getsockopt (fd, SOL_SOCKET, SO_ERROR, (char *) &error_code, &error_size) == SOCKET_ERROR || error_code != 0
333  || css_fd_error (fd) <= 0)
334  {
335  return 1;
336  }
337 
338  return 0;
339 }
340 #endif
341 
342 /*
343  * css_gethostname() - interface for the "gethostname" function
344  * return: 0 if success, or error
345  * name(out): buffer for name
346  * namelen(in): max buffer size
347  */
348 int
349 css_gethostname (char *name, size_t namelen)
350 {
351  const char *pc_name = "PC";
352  char hostname[CUB_MAXHOSTNAMELEN];
353  int err = 0;
354 
355 #if !defined(SERVER_MODE)
356  if (css_windows_startup () < 0)
357  {
358  return -1;
359  }
360 #endif /* not SERVER_MODE */
361 
362  if (gethostname (hostname, CUB_MAXHOSTNAMELEN) != SOCKET_ERROR)
363  {
364  if (strlen (hostname))
365  {
366  pc_name = hostname;
367  }
368  }
369  else
370  {
371  err = WSAGetLastError ();
372  }
373 
374 #if !defined(SERVER_MODE)
376 #endif /* not SERVER_MODE */
377 
378  strncpy (name, pc_name, namelen);
379  return err;
380 }
381 
382 /*
383  * css_gethostid() - returns the hex number that represents this hosts
384  * internet address
385  * return: pseudo-hostid if succesful, 0 if not
386  */
387 unsigned int
389 {
390  struct hostent *hp;
391  char hostname[CUB_MAXHOSTNAMELEN];
392  unsigned int inaddr;
393  unsigned int retval;
394 
395 #if !defined(SERVER_MODE)
396  if (css_windows_startup () < 0)
397  {
398  return 0;
399  }
400 #endif /* not SERVER_MODE */
401 
402  retval = 0;
403  if (gethostname (hostname, CUB_MAXHOSTNAMELEN) == SOCKET_ERROR)
404  {
407  }
408  else
409  {
410  inaddr = inet_addr (hostname);
411  if (inaddr != INADDR_NONE)
412  {
413  retval = inaddr;
414  }
415  else
416  {
417  hp = gethostbyname (hostname);
418  if (hp != NULL)
419  {
420  retval = (*(unsigned int *) hp->h_addr);
421  }
422  else
423  {
425  er_set (ER_ERROR_SEVERITY, ARG_FILE_LINE, ER_CSS_WINSOCK_HOSTID, 1, WSAGetLastError ());
426  }
427  }
428  }
429 
430 #if !defined(SERVER_MODE)
432 #endif /* not SERVER_MODE */
433 
434  return retval;
435 }
436 
437 /*
438  * css_tcp_setup_server_datagram() - datagram stubs
439  * return:
440  * pathname(in):
441  * sockfd(in):
442  *
443  * Note: The Windows platforms do not support this and will instead use the
444  * "new-style" multiple port-id connection interface
445  */
446 bool
447 css_tcp_setup_server_datagram (char *pathname, SOCKET * sockfd)
448 {
449  return false;
450 }
451 
452 /*
453  * css_tcp_listen_server_datagram() - datagram stubs
454  * return:
455  * sockfd(in):
456  * newfd(in):
457  *
458  * Note: The Windows platforms do not support this and will instead use the
459  * "new-style" multiple port-id connection interface
460  */
461 bool
463 {
464  return false;
465 }
466 
467 /*
468  * css_tcp_master_datagram() - datagram stubs
469  * return:
470  * pathname(in):
471  * sockfd(in):
472  *
473  * Note: The Windows platforms do not support this and will instead use the
474  * "new-style" multiple port-id connection interface
475  */
476 bool
477 css_tcp_master_datagram (char *pathname, SOCKET * sockfd)
478 {
479  return false;
480 }
481 
482 /*
483  * css_open_new_socket_from_master() - datagram stubs
484  * return:
485  * fd(in):
486  * rid(in):
487  *
488  * Note: The Windows platforms do not support this and will instead use the
489  * "new-style" multiple port-id connection interface
490  */
491 SOCKET
492 css_open_new_socket_from_master (SOCKET fd, unsigned short *rid)
493 {
494  return INVALID_SOCKET;
495 }
496 
497 /*
498  * css_transfer_fd() - datagram stubs
499  * return:
500  * server_fd(in):
501  * client_fd(in):
502  * rid(in):
503  *
504  * Note: The Windows platforms do not support this and will instead use the
505  * "new-style" multiple port-id connection interface
506  */
507 bool
508 css_transfer_fd (SOCKET server_fd, SOCKET client_fd, unsigned short rid, CSS_SERVER_REQUEST request)
509 {
510  return false;
511 }
512 
513 /* These functions support the new-style connection protocol used by Windows. */
514 
515 /*
516  * css_tcp_master_open() - initialize for the master server internet
517  * communication
518  * return:
519  * port(in):
520  * sockfd(in):
521  */
522 int
523 css_tcp_master_open (int port, SOCKET * sockfd)
524 {
525  struct sockaddr_in tcp_srv_addr; /* server's internet socket addr */
526  SOCKET sock;
527  int retry_count = 0;
528  int bool_value;
529 
530  /*
531  * We have to create a socket ourselves and bind our well-known
532  * address to it.
533  */
534  if (css_windows_startup () < 0)
535  {
536  return ER_CSS_WINSOCK_STARTUP;
537  }
538 
539  memset ((void *) &tcp_srv_addr, 0, sizeof (tcp_srv_addr));
540  tcp_srv_addr.sin_family = AF_INET;
541  tcp_srv_addr.sin_addr.s_addr = htonl (INADDR_ANY);
542 
543  if (port > 0)
544  {
545  tcp_srv_addr.sin_port = htons (port);
546  }
547  else
548  {
551  }
552 
553  /*
554  * Create the socket and Bind our local address so that any
555  * client may send to us.
556  */
557 
558 retry:
559  sock = socket (AF_INET, SOCK_STREAM, 0);
560  if (IS_INVALID_SOCKET (sock))
561  {
563  *sockfd = sock;
565  }
566 
567  /*
568  * Allow the new master to rebind the CUBRID port even if there are
569  * clients with open connections from previous masters.
570  */
571  bool_value = 0;
572  setsockopt (sock, SOL_SOCKET, SO_REUSEADDR, (const char *) &bool_value, sizeof (int));
573 
574  bool_value = 1;
575  setsockopt (sock, IPPROTO_TCP, TCP_NODELAY, (const char *) &bool_value, sizeof (int));
576 
577  if (bind (sock, (struct sockaddr *) &tcp_srv_addr, sizeof (tcp_srv_addr)) == SOCKET_ERROR)
578  {
579  if (WSAGetLastError () == WSAEADDRINUSE && retry_count <= 5)
580  {
581  retry_count++;
582  sleep (1);
583  css_shutdown_socket (sock);
584  goto retry;
585  }
586 
588  css_shutdown_socket (sock);
589  *sockfd = sock;
591  }
592 
593  /*
594  * And set the listen parameter, telling the system that we're
595  * ready to accept incoming connection requests.
596  */
597  listen (sock, css_Maximum_server_count);
598 
599  *sockfd = sock;
600  return NO_ERROR;
601 }
602 
603 /*
604  * css_accept() - accept of a request from a client
605  * return:
606  * sockfd(in):
607  */
608 static SOCKET
610 {
611  struct sockaddr_in tcp_cli_addr;
612  SOCKET newsockfd;
613  int clilen, error;
614 
615  while (true)
616  {
617  clilen = sizeof (tcp_cli_addr);
618  newsockfd = accept (sockfd, (struct sockaddr *) &tcp_cli_addr, &clilen);
619 
620  if (IS_INVALID_SOCKET (newsockfd))
621  {
622  error = WSAGetLastError ();
623  if (error == WSAEINTR)
624  {
625  continue;
626  }
627 
629  return INVALID_SOCKET;
630  }
631 
632  break;
633  }
634 
635  return newsockfd;
636 }
637 
638 
639 /*
640  * css_master_accept() - master accept of a request from a client
641  * return:
642  * sockfd(in):
643  */
644 SOCKET
646 {
647  return css_accept (sockfd);
648 }
649 
650 /*
651  * css_open_server_connection_socket() - open the socket used by the server
652  * for incoming client connection
653  * requests
654  * return: port id
655  */
656 int
658 {
659  struct sockaddr_in tcp_srv_addr; /* server's internet socket addr */
660  SOCKET fd;
661  int get_length;
662  int bool_value;
663 
664 #if !defined(SERVER_MODE)
665  if (css_windows_startup () < 0)
666  {
667  return -1;
668  }
669 #endif /* not SERVER_MODE */
670 
671  /* Create the socket */
672  fd = socket (AF_INET, SOCK_STREAM, 0);
673  if (IS_INVALID_SOCKET (fd))
674  {
676  return -1;
677  }
678 
679  bool_value = 1;
680  setsockopt (fd, IPPROTO_TCP, TCP_NODELAY, (const char *) &bool_value, sizeof (int));
681 
683  {
684  setsockopt (fd, SOL_SOCKET, SO_KEEPALIVE, (const char *) &bool_value, sizeof (int));
685  }
686 
687  /*
688  * Set up an address asking for "any" (the local ?) IP addres
689  * and set the port to zero to it will be automatically assigned.
690  */
691  memset ((void *) &tcp_srv_addr, 0, sizeof (tcp_srv_addr));
692  tcp_srv_addr.sin_family = AF_INET;
693  tcp_srv_addr.sin_addr.s_addr = htonl (INADDR_ANY);
694  tcp_srv_addr.sin_port = 0;
695 
696 
697  /* Bind the socket */
698  if (bind (fd, (struct sockaddr *) &tcp_srv_addr, sizeof (tcp_srv_addr)) == SOCKET_ERROR)
699  {
700  goto error;
701  }
702 
703  /* Determine which port_id the system has assigned. */
704  get_length = sizeof (tcp_srv_addr);
705  if (getsockname (fd, (struct sockaddr *) &tcp_srv_addr, &get_length) == SOCKET_ERROR)
706  {
707  goto error;
708  }
709 
710  /*
711  * Set it up to listen for incoming connections. Note that under Winsock
712  * (NetManage version at least), the backlog parameter is silently limited
713  * to 5, regardless of what is requested.
714  */
715  if (listen (fd, css_Maximum_server_count) == SOCKET_ERROR)
716  {
717  goto error;
718  }
719 
721 
722  return (int) ntohs (tcp_srv_addr.sin_port);
723 
724 error:
726  css_shutdown_socket (fd);
727  return -1;
728 }
729 
730 /*
731  * css_close_server_connection_socket() - Close the socket that was opened by
732  * the server for incoming client
733  * requests
734  * return: void
735  */
736 void
738 {
740  {
741  closesocket (css_Server_connection_socket);
743  }
744 }
745 
746 /*
747  * css_server_accept() - accept an incoming connection on the server's
748  * connection socket
749  * return: the fd of the new connection
750  * sockfd(in):
751  */
752 SOCKET
754 {
755  return css_accept (sockfd);
756 }
757 
758 int
760 {
761  return max_socket_fds;
762 }
763 
764 /*
765  * css_get_peer_name() - get the hostname of the peer socket
766  * return: 0 if success; otherwise errno
767  * hostname(in): buffer for hostname
768  * len(in): size of the hostname buffer
769  */
770 int
771 css_get_peer_name (SOCKET sockfd, char *hostname, size_t len)
772 {
773  struct sockaddr_in saddr_buf;
774  struct sockaddr *saddr;
775  int saddr_len;
776 
777  saddr = (struct sockaddr *) &saddr_buf;
778  saddr_len = sizeof (saddr_buf);
779  if (getpeername (sockfd, saddr, &saddr_len) != 0)
780  {
781  return WSAGetLastError ();
782  }
783  return getnameinfo (saddr, saddr_len, hostname, (DWORD) len, NULL, 0, NI_NOFQDN);
784 }
785 
786 /*
787  * css_get_sock_name() - get the hostname of the socket
788  * return: 0 if success; otherwise errno
789  * hostname(in): buffer for hostname
790  * len(in): size of the hostname buffer
791  */
792 int
793 css_get_sock_name (SOCKET sockfd, char *hostname, size_t len)
794 {
795  struct sockaddr_in saddr_buf;
796  struct sockaddr *saddr;
797  int saddr_len;
798 
799  saddr = (struct sockaddr *) &saddr_buf;
800  saddr_len = sizeof (saddr_buf);
801  if (getsockname (sockfd, saddr, &saddr_len) != 0)
802  {
803  return WSAGetLastError ();
804  }
805  return getnameinfo (saddr, saddr_len, hostname, (DWORD) len, NULL, 0, NI_NOFQDN);
806 }
807 
808 /*
809  * css_hostname_to_ip()
810  * return:
811  * host(in):
812  * ip_addr(out):
813  */
814 int
815 css_hostname_to_ip (const char *host, unsigned char *ip_addr)
816 {
817  unsigned int in_addr;
818  int err = NO_ERROR;
819 
820 #if !defined(SERVER_MODE)
821  if (css_windows_startup () < 0)
822  {
823  return ER_CSS_WINSOCK_STARTUP;
824  }
825 #endif /* not SERVER_MODE */
826 
827  /*
828  * First try to convert to the host name as a dotted-decimal number.
829  * Only if that fails do we call gethostbyname.
830  */
831  in_addr = inet_addr (host);
832  if (in_addr != INADDR_NONE)
833  {
834  memcpy ((void *) ip_addr, (void *) &in_addr, sizeof (in_addr));
835  }
836  else
837  {
838  struct hostent *hp;
839 
840  hp = gethostbyname (host);
841  if (hp == NULL)
842  {
845  }
846  else
847  {
848  memcpy ((void *) ip_addr, (void *) hp->h_addr, hp->h_length);
849  }
850  }
851 
852 #if !defined(SERVER_MODE)
854 #endif /* not SERVER_MODE */
855 
856  return err;
857 }
void css_close_server_connection_socket(void)
Definition: wintcp.c:737
static int css_Wsa_error
Definition: wintcp.c:58
#define NO_ERROR
Definition: error_code.h:46
SOCKET css_tcp_client_open(const char *host_name, int port)
Definition: wintcp.c:164
int SOCKET
Definition: porting.h:482
int css_open_server_connection_socket(void)
Definition: wintcp.c:657
unsigned int htonl(unsigned int from)
#define ER_CSS_WINSOCK_HOSTID
Definition: error_code.h:740
bool css_tcp_listen_server_datagram(SOCKET sockfd, SOCKET *newfd)
Definition: wintcp.c:462
#define ERR_CSS_WINTCP_PORT_ERROR
Definition: error_code.h:915
int css_gethostname(char *name, size_t namelen)
Definition: wintcp.c:349
int css_hostname_to_ip(const char *host, unsigned char *ip_addr)
Definition: wintcp.c:815
int css_get_peer_name(SOCKET sockfd, char *hostname, size_t len)
Definition: wintcp.c:771
#define INVALID_SOCKET
Definition: porting.h:483
int css_get_max_socket_fds(void)
Definition: wintcp.c:759
#define INADDR_NONE
Definition: tcp.c:89
bool css_windows_blocking_hook(void)
Definition: wintcp.c:84
void er_set(int severity, const char *file_name, const int line_no, int err_id, int num_args,...)
static int max_socket_fds
Definition: wintcp.c:60
static unsigned int wsa_Init_count
Definition: wintcp.c:62
static const int css_Tcp_max_connect_tries
Definition: wintcp.c:54
int css_get_sock_name(SOCKET sockfd, char *hostname, size_t len)
Definition: wintcp.c:793
bool css_transfer_fd(SOCKET server_fd, SOCKET client_fd, unsigned short rid, CSS_SERVER_REQUEST request)
Definition: wintcp.c:508
#define IS_INVALID_SOCKET(socket)
Definition: porting.h:484
SOCKET css_tcp_client_open_with_retry(const char *host_name, int port, bool will_retry)
Definition: wintcp.c:184
bool css_tcp_master_datagram(char *pathname, SOCKET *sockfd)
Definition: wintcp.c:477
#define NULL
Definition: freelistheap.h:34
SOCKET css_server_accept(SOCKET sockfd)
Definition: wintcp.c:753
unsigned short htons(unsigned short from)
static int success()
SOCKET css_Server_connection_socket
#define err(fd,...)
Definition: porting.h:431
void er_set_with_oserror(int severity, const char *file_name, const int line_no, int err_id, int num_args,...)
int count(int &result, const cub_regex_object &reg, const std::string &src, const int position, const INTL_CODESET codeset)
#define ER_CSS_WINSOCK_STARTUP
Definition: error_code.h:738
bool css_tcp_setup_server_datagram(char *pathname, SOCKET *sockfd)
Definition: wintcp.c:447
static void error(const char *msg)
Definition: gencat.c:331
static int rc
Definition: serial.c:50
#define ARG_FILE_LINE
Definition: error_manager.h:44
static SOCKET css_accept(SOCKET sockfd)
Definition: wintcp.c:609
unsigned int css_gethostid(void)
Definition: wintcp.c:388
static const int css_Maximum_server_count
Definition: wintcp.c:55
static unsigned int css_fd_error(SOCKET fd)
Definition: wintcp.c:306
int css_windows_startup(void)
Definition: wintcp.c:94
unsigned short ntohs(unsigned short from)
#define strlen(s1)
Definition: intl_support.c:43
static FARPROC old_hook
Definition: wintcp.c:59
void css_windows_shutdown(void)
Definition: wintcp.c:140
bool prm_get_bool_value(PARAM_ID prm_id)
#define ERR_CSS_WINTCP_BIND_ABORT
Definition: error_code.h:918
int css_tcp_master_open(int port, SOCKET *sockfd)
Definition: wintcp.c:523
#define ERR_CSS_TCP_CANNOT_CONNECT_TO_MASTER
Definition: error_code.h:429
enum css_server_request CSS_SERVER_REQUEST
SOCKET css_open_new_socket_from_master(SOCKET fd, unsigned short *rid)
Definition: wintcp.c:492
#define ERR_CSS_WINTCP_CANNOT_CREATE_STREAM
Definition: error_code.h:916
#define ER_CSS_WINSOCK_HOSTNAME
Definition: error_code.h:739
#define CUB_MAXHOSTNAMELEN
Definition: porting.h:379
static char * host
SOCKET css_master_accept(SOCKET sockfd)
Definition: wintcp.c:645
void css_shutdown_socket(SOCKET fd)
Definition: wintcp.c:292
#define ERR_CSS_WINTCP_ACCEPT_ERROR
Definition: error_code.h:919