Mercurial > pidgin
comparison plugins/icq/tcplink.c @ 1498:0ef6603d986e
[gaim-migrate @ 1508]
updating icqlib
committer: Tailor Script <tailor@pidgin.im>
author | Eric Warmenhoven <eric@warmenhoven.org> |
---|---|
date | Thu, 22 Feb 2001 23:07:34 +0000 |
parents | 4c510ca3563f |
children | e06dcc3025a9 |
comparison
equal
deleted
inserted
replaced
1497:c3a40af2b0c4 | 1498:0ef6603d986e |
---|---|
1 /* -*- Mode: C; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ | 1 /* -*- Mode: C; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ |
2 /* | 2 /* |
3 $Id: tcplink.c 1442 2001-01-28 01:52:27Z warmenhoven $ | 3 $Id: tcplink.c 1508 2001-02-22 23:07:34Z warmenhoven $ |
4 $Log$ | 4 $Log$ |
5 Revision 1.3 2001/01/28 01:52:27 warmenhoven | 5 Revision 1.4 2001/02/22 23:07:34 warmenhoven |
6 icqlib 1.1.5 | 6 updating icqlib |
7 | |
8 Revision 1.44 2001/02/22 05:40:04 bills | |
9 port tcp connect timeout code and UDP queue to new timeout manager | |
7 | 10 |
8 Revision 1.43 2001/01/27 22:48:01 bills | 11 Revision 1.43 2001/01/27 22:48:01 bills |
9 fix bugs related to TCP and new socket manager: implemented accepting TCP | 12 fix bugs related to TCP and new socket manager: implemented accepting TCP |
10 sockets, fixed crashes when sending TCP messages. | 13 sockets, fixed crashes when sending TCP messages. |
11 | 14 |
209 p->id=0; | 212 p->id=0; |
210 p->remote_uin=0; | 213 p->remote_uin=0; |
211 p->remote_version=0; | 214 p->remote_version=0; |
212 p->flags=0; | 215 p->flags=0; |
213 p->proxy_status = 0; | 216 p->proxy_status = 0; |
217 p->connect_timeout = NULL; | |
214 | 218 |
215 if(p) | 219 if(p) |
216 list_enqueue(link->d->icq_TCPLinks, p); | 220 list_enqueue(link->d->icq_TCPLinks, p); |
217 | 221 |
218 return p; | 222 return p; |
265 | 269 |
266 /* close the socket after we notify app so app can read errno if necessary */ | 270 /* close the socket after we notify app so app can read errno if necessary */ |
267 if (p->socket > -1) | 271 if (p->socket > -1) |
268 { | 272 { |
269 icq_SocketDelete(p->socket); | 273 icq_SocketDelete(p->socket); |
274 } | |
275 | |
276 if (p->connect_timeout) | |
277 { | |
278 icq_TimeoutDelete(p->connect_timeout); | |
270 } | 279 } |
271 | 280 |
272 free(p); | 281 free(p); |
273 } | 282 } |
274 | 283 |
581 | 590 |
582 plink->mode|=TCP_LINK_MODE_CONNECTING; | 591 plink->mode|=TCP_LINK_MODE_CONNECTING; |
583 | 592 |
584 plink->remote_uin=uin; | 593 plink->remote_uin=uin; |
585 | 594 |
586 plink->connect_time=time(0L); | |
587 | |
588 /* Send the hello packet */ | 595 /* Send the hello packet */ |
589 p=icq_TCPCreateInitPacket(plink); | 596 p=icq_TCPCreateInitPacket(plink); |
590 icq_TCPLinkSend(plink, p); | 597 icq_TCPLinkSend(plink, p); |
591 | 598 |
592 #ifdef TCP_PACKET_TRACE | 599 #ifdef TCP_PACKET_TRACE |
593 printf("hello packet queued for %lu\n", uin); | 600 printf("hello packet queued for %lu\n", uin); |
594 #endif /* TCP_PACKET_TRACE */ | 601 #endif /* TCP_PACKET_TRACE */ |
595 | 602 |
596 icq_SocketSetHandler(plink->socket, ICQ_SOCKET_WRITE, | 603 icq_SocketSetHandler(plink->socket, ICQ_SOCKET_WRITE, |
597 icq_TCPLinkOnConnect, plink); | 604 icq_TCPLinkOnConnect, plink); |
605 plink->connect_timeout=icq_TimeoutNew(TCP_LINK_CONNECT_TIMEOUT, | |
606 (icq_TimeoutHandler)icq_TCPLinkClose, plink); | |
598 | 607 |
599 return 1; | 608 return 1; |
600 } | 609 } |
601 | 610 |
602 icq_TCPLink *icq_TCPLinkAccept(icq_TCPLink *plink) | 611 icq_TCPLink *icq_TCPLinkAccept(icq_TCPLink *plink) |
841 #else | 850 #else |
842 size_t len; | 851 size_t len; |
843 #endif | 852 #endif |
844 int error; | 853 int error; |
845 | 854 |
855 icq_TimeoutDelete(plink->connect_timeout); | |
856 plink->connect_timeout = NULL; | |
857 | |
846 /* check getsockopt */ | 858 /* check getsockopt */ |
847 len=sizeof(error); | 859 len=sizeof(error); |
848 | 860 |
849 #ifdef _WIN32 | 861 #ifdef _WIN32 |
850 getsockopt(plink->socket, SOL_SOCKET, SO_ERROR, (char *)&error, &len); | 862 getsockopt(plink->socket, SOL_SOCKET, SO_ERROR, (char *)&error, &len); |