2 * WINGs WMConnection function library
4 * Copyright (c) 1999-2000 Dan Pascu
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License, or
9 * (at your option) any later version.
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
24 * - decide if we want to support connections with external sockets, else
25 * clean up the structure of the unneeded members.
26 * - decide what to do with all wwarning() calls that are still there.
31 #include "../src/config.h"
40 #include <sys/socket.h>
41 #include <netinet/in.h>
42 #include <arpa/inet.h>
46 #include <sys/signal.h>
52 /* Some older systems does not define this (linux libc5, maybe others too) */
64 # define INADDR_NONE -1
67 /* Stuff for setting the sockets into non-blocking mode. */
68 /*#ifdef __POSIX_SOURCE
69 # define NONBLOCK_OPT O_NONBLOCK
71 # define NONBLOCK_OPT FNDELAY
74 #define NONBLOCK_OPT O_NONBLOCK
76 #define NETBUF_SIZE 4096
78 #define DEF_TIMEOUT 600 /* 600 seconds == 10 minutes */
84 static Bool SigInitialized
= False
;
86 static unsigned int DefaultTimeout
= DEF_TIMEOUT
;
87 static unsigned int OpenTimeout
= DEF_TIMEOUT
;
91 typedef struct TimeoutData
{
97 typedef struct W_Connection
{
98 int sock
; /* the socket we speak through */
101 WMHandlerID
*read
; /* the input read handler */
102 WMHandlerID
*write
; /* the input write handler */
103 WMHandlerID
*exception
; /* the input exception handler */
106 ConnectionDelegate
*delegate
; /* client delegates */
107 void *clientData
; /* client data */
108 unsigned int uflags
; /* flags for the client */
110 WMArray
*outputQueue
;
113 TimeoutData sendTimeout
;
114 TimeoutData openTimeout
;
116 WMConnectionState state
;
117 WMConnectionTimeoutState timeoutState
;
132 clearOutputQueue(WMConnection
*cPtr
) /*FOLD00*/
135 WMEmptyArray(cPtr
->outputQueue
);
140 openTimeout(void *cdata
) /*FOLD00*/
142 WMConnection
*cPtr
= (WMConnection
*) cdata
;
144 cPtr
->openTimeout
.handler
= NULL
;
145 if (cPtr
->handler
.write
) {
146 WMDeleteInputHandler(cPtr
->handler
.write
);
147 cPtr
->handler
.write
= NULL
;
149 if (cPtr
->state
!= WCConnected
) {
150 cPtr
->state
= WCTimedOut
;
151 cPtr
->timeoutState
= WCTWhileOpening
;
152 if (cPtr
->delegate
&& cPtr
->delegate
->didTimeout
) {
153 (*cPtr
->delegate
->didTimeout
)(cPtr
->delegate
, cPtr
);
155 WMCloseConnection(cPtr
);
156 cPtr
->state
= WCTimedOut
; /* the above set state to WCClosed */
163 sendTimeout(void *cdata
) /*FOLD00*/
165 WMConnection
*cPtr
= (WMConnection
*) cdata
;
167 cPtr
->sendTimeout
.handler
= NULL
;
168 if (cPtr
->handler
.write
) {
169 WMDeleteInputHandler(cPtr
->handler
.write
);
170 cPtr
->handler
.write
= NULL
;
172 if (WMGetArrayItemCount(cPtr
->outputQueue
)>0) {
173 clearOutputQueue(cPtr
);
174 cPtr
->state
= WCTimedOut
;
175 cPtr
->timeoutState
= WCTWhileSending
;
176 if (cPtr
->delegate
&& cPtr
->delegate
->didTimeout
) {
177 (*cPtr
->delegate
->didTimeout
)(cPtr
->delegate
, cPtr
);
179 WMCloseConnection(cPtr
);
180 cPtr
->state
= WCTimedOut
; /* the above set state to WCClosed */
187 inputHandler(int fd
, int mask
, void *clientData
) /*FOLD00*/
189 WMConnection
*cPtr
= (WMConnection
*)clientData
;
191 if (cPtr
->state
==WCClosed
|| cPtr
->state
==WCDied
)
194 if ((mask
& WIWriteMask
)) {
195 if (cPtr
->state
== WCInProgress
) {
198 int len
= sizeof(result
);
201 if (getsockopt(cPtr
->sock
, SOL_SOCKET
, SO_ERROR
,
202 (void*)&result
, &len
) == 0 && result
!= 0) {
203 cPtr
->state
= WCFailed
;
204 WCErrorCode
= result
;
206 /* should call wsyserrorwithcode(result, ...) here? */
208 cPtr
->state
= WCConnected
;
212 if (cPtr
->handler
.write
) {
213 WMDeleteInputHandler(cPtr
->handler
.write
);
214 cPtr
->handler
.write
= NULL
;
217 if (cPtr
->openTimeout
.handler
) {
218 WMDeleteTimerHandler(cPtr
->openTimeout
.handler
);
219 cPtr
->openTimeout
.handler
= NULL
;
222 if (cPtr
->delegate
&& cPtr
->delegate
->didInitialize
)
223 (*cPtr
->delegate
->didInitialize
)(cPtr
->delegate
, cPtr
);
225 /* we use failed and not cPtr->state here, because cPtr may be
226 * destroyed by the delegate called above if the connection failed
230 } else if (cPtr
->state
== WCConnected
) {
231 WMFlushConnection(cPtr
);
238 /* if the connection died, may get destroyed in the delegate, so retain */
241 if ((mask
& WIReadMask
) && cPtr
->delegate
->didReceiveInput
)
242 (*cPtr
->delegate
->didReceiveInput
)(cPtr
->delegate
, cPtr
);
244 if ((mask
& WIExceptMask
) && cPtr
->delegate
->didCatchException
)
245 (*cPtr
->delegate
->didCatchException
)(cPtr
->delegate
, cPtr
);
252 setSocketNonBlocking(int sock
, Bool flag
) /*FOLD00*/
257 state
= fcntl(sock
, F_GETFL
, 0);
260 /* set WCErrorCode here? -Dan*/
264 isNonBlock
= (state
& NONBLOCK_OPT
) != 0;
269 state
|= NONBLOCK_OPT
;
273 state
&= ~NONBLOCK_OPT
;
276 if (fcntl(sock
, F_SETFL
, state
) < 0) {
277 /* set WCErrorCode here? -Dan*/
286 setConnectionAddress(WMConnection
*cPtr
, struct sockaddr_in
*socketaddr
) /*FOLD00*/
288 wassertr(cPtr
->address
==NULL
);
290 cPtr
->address
= wstrdup(inet_ntoa(socketaddr
->sin_addr
));
291 cPtr
->service
= wmalloc(16);
292 sprintf(cPtr
->service
, "%hu", ntohs(socketaddr
->sin_port
));
293 cPtr
->protocol
= wstrdup("tcp");
297 static struct sockaddr_in
*
298 getSocketAddress(char* name
, char* service
, char* protocol
) /*FOLD00*/
300 static struct sockaddr_in socketaddr
;
303 if (!protocol
|| protocol
[0]==0)
306 memset(&socketaddr
, 0, sizeof(struct sockaddr_in
));
307 socketaddr
.sin_family
= AF_INET
;
310 * If we were given a hostname, we use any address for that host.
311 * Otherwise we expect the given name to be an address unless it is
312 * NULL (any address).
314 if (name
&& name
[0]!=0) {
315 WMHost
*host
= WMGetHostWithName(name
);
318 return NULL
; /* name is not a hostname nor a number and dot adr */
320 name
= WMGetHostAddress(host
);
321 #ifndef HAVE_INET_ATON
322 if ((socketaddr
.sin_addr
.s_addr
= inet_addr(name
)) == INADDR_NONE
) {
324 if (inet_aton(name
, &socketaddr
.sin_addr
) == 0) {
331 socketaddr
.sin_addr
.s_addr
= htonl(INADDR_ANY
);
334 if (!service
|| service
[0]==0) {
335 socketaddr
.sin_port
= 0;
336 } else if ((sp
= getservbyname(service
, protocol
))==0) {
340 portNumber
= strtoul(service
, &endptr
, 10);
342 if (service
[0]!=0 && *endptr
==0 && portNumber
<65536) {
343 socketaddr
.sin_port
= htons(portNumber
);
348 socketaddr
.sin_port
= sp
->s_port
;
356 createConnectionWithSocket(int sock
, Bool closeOnRelease
) /*FOLD00*/
359 struct sigaction sig_action
;
361 cPtr
= wmalloc(sizeof(WMConnection
));
363 memset(cPtr
, 0, sizeof(WMConnection
));
365 fcntl(sock
, F_SETFD
, FD_CLOEXEC
); /* by default close on exec */
368 cPtr
->openTimeout
.timeout
= OpenTimeout
;
369 cPtr
->openTimeout
.handler
= NULL
;
370 cPtr
->sendTimeout
.timeout
= DefaultTimeout
;
371 cPtr
->sendTimeout
.handler
= NULL
;
372 cPtr
->closeOnRelease
= closeOnRelease
;
374 WMCreateArrayWithDestructor(16, (WMFreeDataProc
*)WMReleaseData
);
375 cPtr
->state
= WCNotConnected
;
376 cPtr
->timeoutState
= WCTNone
;
378 /* ignore dead pipe */
379 if (!SigInitialized
) {
380 sig_action
.sa_handler
= SIG_IGN
;
381 sig_action
.sa_flags
= SA_RESTART
;
382 sigaction(SIGPIPE
, &sig_action
, NULL
);
383 SigInitialized
= True
;
392 WMCreateConnectionWithSocket(int sock
, Bool closeOnRelease
) /*FOLD00*/
395 struct sockaddr_in clientname
;
399 cPtr
= createConnectionWithSocket(sock
, closeOnRelease
);
400 cPtr
->wasNonBlocking
= WMIsConnectionNonBlocking(cPtr
);
401 cPtr
->isNonBlocking
= cPtr
->wasNonBlocking
;
403 /* some way to find out if it is connected, and binded. can't find
404 if it listens though!!!
407 size
= sizeof(clientname
);
408 n
= getpeername(sock
, (struct sockaddr
*) &clientname
, &size
);
410 /* Since we have a peer, it means we are connected */
411 cPtr
->state
= WCConnected
;
413 size
= sizeof(clientname
);
414 n
= getsockname(sock
, (struct sockaddr
*) &clientname
, &size
);
416 /* We don't have a peer, but we are binded to an address.
417 * Assume we are listening on it (we don't know that for sure!)
419 cPtr
->state
= WCListening
;
421 cPtr
->state
= WCNotConnected
;
431 * host is the name on which we want to listen for incoming connections,
432 * and it must be a name of this host, or NULL if we want to listen
433 * on any incoming address.
434 * service is either a service name as present in /etc/services, or the port
435 * number we want to listen on. If NULL, a random port between
436 * 1024 and 65535 will be assigned to us.
437 * protocol is one of "tcp" or "udp". If NULL, "tcp" will be used by default.
438 * currently only "tcp" is supported.
441 WMCreateConnectionAsServerAtAddress(char *host
, char *service
, char *protocol
) /*FOLD00*/
444 struct sockaddr_in
*socketaddr
;
450 if ((socketaddr
= getSocketAddress(host
, service
, protocol
)) == NULL
) {
451 wwarning("Bad address-service-protocol combination");
455 /* Create the actual socket */
456 sock
= socket(PF_INET
, SOCK_STREAM
, 0);
463 * Set socket options. We try to make the port reusable and have it
464 * close as fast as possible without waiting in unnecessary wait states
468 setsockopt(sock
, SOL_SOCKET
, SO_REUSEADDR
, (void *)&on
, sizeof(on
));
470 if (bind(sock
, (struct sockaddr
*)socketaddr
, sizeof(*socketaddr
)) < 0) {
476 if (listen(sock
, 10) < 0) {
482 /* Find out what is the address/service/protocol we get */
483 /* In case some of address/service/protocol were NULL */
484 size
= sizeof(*socketaddr
);
485 if (getsockname(sock
, (struct sockaddr
*)socketaddr
, &size
) < 0) {
491 cPtr
= createConnectionWithSocket(sock
, True
);
492 cPtr
->state
= WCListening
;
493 WMSetConnectionNonBlocking(cPtr
, True
);
495 setConnectionAddress(cPtr
, socketaddr
);
502 WMCreateConnectionToAddress(char *host
, char *service
, char *protocol
) /*FOLD00*/
505 struct sockaddr_in
*socketaddr
;
510 wassertrv(service
!=NULL
&& service
[0]!=0, NULL
);
512 if (host
==NULL
|| host
[0]==0)
515 if ((socketaddr
= getSocketAddress(host
, service
, protocol
)) == NULL
) {
516 wwarning("Bad address-service-protocol combination");
520 /* Create the actual socket */
521 sock
= socket(PF_INET
, SOCK_STREAM
, 0);
526 /* make socket blocking while we connect. */
527 setSocketNonBlocking(sock
, False
);
528 if (connect(sock
, (struct sockaddr
*)socketaddr
, sizeof(*socketaddr
)) < 0) {
534 cPtr
= createConnectionWithSocket(sock
, True
);
535 cPtr
->state
= WCConnected
;
536 WMSetConnectionNonBlocking(cPtr
, True
);
537 setConnectionAddress(cPtr
, socketaddr
);
544 WMCreateConnectionToAddressAndNotify(char *host
, char *service
, char *protocol
) /*FOLD00*/
547 struct sockaddr_in
*socketaddr
;
553 wassertrv(service
!=NULL
&& service
[0]!=0, NULL
);
555 if (host
==NULL
|| host
[0]==0)
558 if ((socketaddr
= getSocketAddress(host
, service
, protocol
)) == NULL
) {
559 wwarning("Bad address-service-protocol combination");
563 /* Create the actual socket */
564 sock
= socket(PF_INET
, SOCK_STREAM
, 0);
569 isNonBlocking
= setSocketNonBlocking(sock
, True
);
570 if (connect(sock
, (struct sockaddr
*)socketaddr
, sizeof(*socketaddr
)) < 0) {
571 if (errno
!=EINPROGRESS
) {
578 cPtr
= createConnectionWithSocket(sock
, True
);
579 cPtr
->state
= WCInProgress
;
580 cPtr
->isNonBlocking
= isNonBlocking
;
582 cPtr
->handler
.write
= WMAddInputHandler(cPtr
->sock
, WIWriteMask
,
585 cPtr
->openTimeout
.handler
=
586 WMAddTimerHandler(cPtr
->openTimeout
.timeout
*1000, openTimeout
, cPtr
);
588 setConnectionAddress(cPtr
, socketaddr
);
595 removeAllHandlers(WMConnection
*cPtr
) /*FOLD00*/
597 if (cPtr
->handler
.read
)
598 WMDeleteInputHandler(cPtr
->handler
.read
);
599 if (cPtr
->handler
.write
)
600 WMDeleteInputHandler(cPtr
->handler
.write
);
601 if (cPtr
->handler
.exception
)
602 WMDeleteInputHandler(cPtr
->handler
.exception
);
603 if (cPtr
->openTimeout
.handler
)
604 WMDeleteTimerHandler(cPtr
->openTimeout
.handler
);
605 if (cPtr
->sendTimeout
.handler
)
606 WMDeleteTimerHandler(cPtr
->sendTimeout
.handler
);
608 cPtr
->handler
.read
= NULL
;
609 cPtr
->handler
.write
= NULL
;
610 cPtr
->handler
.exception
= NULL
;
611 cPtr
->openTimeout
.handler
= NULL
;
612 cPtr
->sendTimeout
.handler
= NULL
;
617 WMDestroyConnection(WMConnection
*cPtr
) /*FOLD00*/
619 if (cPtr
->closeOnRelease
&& cPtr
->sock
>=0) {
620 shutdown(cPtr
->sock
, SHUT_RDWR
);
624 removeAllHandlers(cPtr
);
625 WMFreeArray(cPtr
->outputQueue
); /* will also free the items with the destructor */
628 wfree(cPtr
->address
);
629 wfree(cPtr
->service
);
630 wfree(cPtr
->protocol
);
638 WMCloseConnection(WMConnection
*cPtr
) /*FOLD00*/
641 shutdown(cPtr
->sock
, SHUT_RDWR
);
646 removeAllHandlers(cPtr
);
647 clearOutputQueue(cPtr
);
649 cPtr
->state
= WCClosed
;
654 WMAcceptConnection(WMConnection
*listener
) /*FOLD00*/
656 struct sockaddr_in clientname
;
659 WMConnection
*newConnection
;
662 wassertrv(listener
&& listener
->state
==WCListening
, NULL
);
664 size
= sizeof(clientname
);
665 newSock
= accept(listener
->sock
, (struct sockaddr
*) &clientname
, &size
);
667 WCErrorCode
= ((errno
!=EAGAIN
&& errno
!=EWOULDBLOCK
) ? errno
: 0);
671 newConnection
= createConnectionWithSocket(newSock
, True
);
672 WMSetConnectionNonBlocking(newConnection
, True
);
673 newConnection
->state
= WCConnected
;
674 setConnectionAddress(newConnection
, &clientname
);
676 return newConnection
;
681 WMGetConnectionAddress(WMConnection
*cPtr
) /*FOLD00*/
683 return cPtr
->address
;
688 WMGetConnectionService(WMConnection
*cPtr
) /*FOLD00*/
690 return cPtr
->service
;
695 WMGetConnectionProtocol(WMConnection
*cPtr
) /*FOLD00*/
697 return cPtr
->protocol
;
702 WMGetConnectionSocket(WMConnection
*cPtr
) /*FOLD00*/
709 WMGetConnectionState(WMConnection
*cPtr
) /*FOLD00*/
715 WMConnectionTimeoutState
716 WMGetConnectionTimeoutState(WMConnection
*cPtr
) /*FOLD00*/
718 return cPtr
->timeoutState
;
723 WMEnqueueConnectionData(WMConnection
*cPtr
, WMData
*data
) /*FOLD00*/
725 wassertrv(cPtr
->state
!=WCNotConnected
&& cPtr
->state
!=WCListening
, False
);
726 wassertrv(cPtr
->state
!=WCInProgress
&& cPtr
->state
!=WCFailed
, False
);
728 if (cPtr
->state
!=WCConnected
)
731 WMAddToArray(cPtr
->outputQueue
, WMRetainData(data
));
737 WMSendConnectionData(WMConnection
*cPtr
, WMData
*data
) /*FOLD00*/
739 int bytes
, pos
, len
, totalTransfer
;
740 TimeoutData
*tPtr
= &cPtr
->sendTimeout
;
741 const unsigned char *dataBytes
;
743 wassertrv(cPtr
->state
!=WCNotConnected
&& cPtr
->state
!=WCListening
, -1);
744 wassertrv(cPtr
->state
!=WCInProgress
&& cPtr
->state
!=WCFailed
, -1);
746 if (cPtr
->state
!=WCConnected
)
749 /* If we have no data just flush the queue, else try to send data */
750 if (data
&& WMGetDataLength(data
)>0) {
751 WMAddToArray(cPtr
->outputQueue
, WMRetainData(data
));
752 /* If there already was something in queue, and also a write input
753 * handler is established, it means we were unable to send, so
754 * return and let the write handler notify us when we can send.
756 if (WMGetArrayItemCount(cPtr
->outputQueue
)>1 && cPtr
->handler
.write
)
762 while (WMGetArrayItemCount(cPtr
->outputQueue
) > 0) {
763 data
= WMGetFromArray(cPtr
->outputQueue
, 0);
764 dataBytes
= (const unsigned char *)WMDataBytes(data
);
765 len
= WMGetDataLength(data
);
766 pos
= cPtr
->bufPos
; /* where we're left last time */
769 bytes
= write(cPtr
->sock
, dataBytes
+pos
, len
- pos
);
775 /* save the position where we're left and add a timeout */
777 if (!tPtr
->handler
) {
778 tPtr
->handler
= WMAddTimerHandler(tPtr
->timeout
*1000,
781 if (!cPtr
->handler
.write
) {
782 cPtr
->handler
.write
=
783 WMAddInputHandler(cPtr
->sock
, WIWriteMask
,
786 return totalTransfer
;
789 cPtr
->state
= WCDied
;
790 removeAllHandlers(cPtr
);
791 if (cPtr
->delegate
&& cPtr
->delegate
->didDie
)
792 (*cPtr
->delegate
->didDie
)(cPtr
->delegate
, cPtr
);
797 totalTransfer
+= bytes
;
799 WMDeleteFromArray(cPtr
->outputQueue
, 0);
802 WMDeleteTimerHandler(tPtr
->handler
);
803 tPtr
->handler
= NULL
;
805 if (cPtr
->handler
.write
) {
806 WMDeleteInputHandler(cPtr
->handler
.write
);
807 cPtr
->handler
.write
= NULL
;
811 return totalTransfer
;
816 * WMGetConnectionAvailableData(connection):
818 * will return a WMData structure containing the available data on the
819 * specified connection. If connection is non-blocking (default) and no data
820 * is available when this function is called, an empty WMData is returned.
822 * If an error occurs while reading or the other side closed connection,
823 * it will return NULL.
824 * Also trying to read from an already died or closed connection is
825 * considered to be an error condition, and will return NULL.
828 WMGetConnectionAvailableData(WMConnection
*cPtr
) /*FOLD00*/
830 char buffer
[NETBUF_SIZE
];
834 wassertrv(cPtr
->state
!=WCNotConnected
&& cPtr
->state
!=WCListening
, NULL
);
835 wassertrv(cPtr
->state
!=WCInProgress
&& cPtr
->state
!=WCFailed
, NULL
);
837 if (cPtr
->state
!=WCConnected
)
843 nbytes
= read(cPtr
->sock
, buffer
, NETBUF_SIZE
);
849 aData
= WMCreateDataWithCapacity(0);
853 cPtr
->state
= WCDied
;
854 removeAllHandlers(cPtr
);
855 if (cPtr
->delegate
&& cPtr
->delegate
->didDie
)
856 (*cPtr
->delegate
->didDie
)(cPtr
->delegate
, cPtr
);
859 } else if (nbytes
==0) { /* the other side has closed connection */
860 cPtr
->state
= WCClosed
;
861 removeAllHandlers(cPtr
);
862 if (cPtr
->delegate
&& cPtr
->delegate
->didDie
)
863 (*cPtr
->delegate
->didDie
)(cPtr
->delegate
, cPtr
);
865 aData
= WMCreateDataWithBytes(buffer
, nbytes
);
873 WMSetConnectionDelegate(WMConnection
*cPtr
, ConnectionDelegate
*delegate
) /*FOLD00*/
875 wassertr(cPtr
->sock
>= 0);
876 /* Don't try to set the delegate multiple times */
877 wassertr(cPtr
->delegate
== NULL
);
879 cPtr
->delegate
= delegate
;
880 if (delegate
&& delegate
->didReceiveInput
&& !cPtr
->handler
.read
)
881 cPtr
->handler
.read
= WMAddInputHandler(cPtr
->sock
, WIReadMask
,
883 if (delegate
&& delegate
->didCatchException
&& !cPtr
->handler
.exception
)
884 cPtr
->handler
.exception
= WMAddInputHandler(cPtr
->sock
, WIExceptMask
,
891 WMIsConnectionNonBlocking(WMConnection
*cPtr
) /*FOLD00*/
896 state
= fcntl(cPtr
->sock
, F_GETFL
, 0);
899 /* If we can't use fcntl on socket, this probably also means we could
900 * not use fcntl to set non-blocking mode, and since a socket defaults
901 * to blocking when created, return False as the best assumption */
905 return ((state
& NONBLOCK_OPT
)!=0);
907 return cPtr
->isNonBlocking
;
914 WMSetConnectionNonBlocking(WMConnection
*cPtr
, Bool flag
) /*FOLD00*/
916 wassertrv(cPtr
!=NULL
&& cPtr
->sock
>=0, False
);
918 if (cPtr
->isNonBlocking
== flag
)
921 if (setSocketNonBlocking(cPtr
->sock
, flag
)==True
) {
922 cPtr
->isNonBlocking
= flag
;
931 WMSetConnectionCloseOnExec(WMConnection
*cPtr
, Bool flag
)
933 wassertrv(cPtr
!=NULL
&& cPtr
->sock
>=0, False
);
935 if (fcntl(cPtr
->sock
, F_SETFD
, (flag
? FD_CLOEXEC
: 0)) < 0) {
944 WMGetConnectionClientData(WMConnection
*cPtr
) /*FOLD00*/
946 return cPtr
->clientData
;
951 WMSetConnectionClientData(WMConnection
*cPtr
, void *data
) /*FOLD00*/
953 cPtr
->clientData
= data
;
958 WMGetConnectionFlags(WMConnection
*cPtr
) /*FOLD00*/
965 WMSetConnectionFlags(WMConnection
*cPtr
, unsigned int flags
) /*FOLD00*/
967 cPtr
->uflags
= flags
;
972 WMGetConnectionUnsentData(WMConnection
*cPtr
)
974 return cPtr
->outputQueue
;
979 WMSetConnectionDefaultTimeout(unsigned int timeout
) /*FOLD00*/
982 DefaultTimeout
= DEF_TIMEOUT
;
984 DefaultTimeout
= timeout
;
990 WMSetConnectionOpenTimeout(unsigned int timeout
) /*FOLD00*/
993 OpenTimeout
= DefaultTimeout
;
995 OpenTimeout
= timeout
;
1001 WMSetConnectionSendTimeout(WMConnection
*cPtr
, unsigned int timeout
) /*FOLD00*/
1004 cPtr
->sendTimeout
.timeout
= DefaultTimeout
;
1006 cPtr
->sendTimeout
.timeout
= timeout
;