comparison libpurple/protocols/qq/qq_proxy.c @ 20347:04fe5601fedb

applied changes from 2762c6075c0dc52a96098c5478c5bf68cfd890a3 through 8548e491a5b470d5665cb1cf87a7b0caaa3c87a5
author Luke Schierer <lschiere@pidgin.im>
date Sun, 21 Oct 2007 04:46:33 +0000
parents 44b4e8bd759b
children 35b4f1dc4c8d
comparison
equal deleted inserted replaced
20346:07c2e60026da 20347:04fe5601fedb
256 256
257 /* returns -1 if fails, otherwise returns the file handle */ 257 /* returns -1 if fails, otherwise returns the file handle */
258 static gint _qq_proxy_none(struct PHB *phb, struct sockaddr *addr, socklen_t addrlen) 258 static gint _qq_proxy_none(struct PHB *phb, struct sockaddr *addr, socklen_t addrlen)
259 { 259 {
260 gint fd = -1; 260 gint fd = -1;
261 int flags;
261 262
262 purple_debug(PURPLE_DEBUG_INFO, "QQ", "Using UDP without proxy\n"); 263 purple_debug(PURPLE_DEBUG_INFO, "QQ", "Using UDP without proxy\n");
263 fd = socket(PF_INET, SOCK_DGRAM, 0); 264 fd = socket(PF_INET, SOCK_DGRAM, 0);
264 265
265 if (fd < 0) { 266 if (fd < 0) {
267 "Unable to create socket: %s\n", strerror(errno)); 268 "Unable to create socket: %s\n", strerror(errno));
268 return -1; 269 return -1;
269 } 270 }
270 271
271 /* we use non-blocking mode to speed up connection */ 272 /* we use non-blocking mode to speed up connection */
272 fcntl(fd, F_SETFL, O_NONBLOCK); 273 flags = fcntl(fd, F_GETFL);
274 fcntl(fd, F_SETFL, flags | O_NONBLOCK);
273 275
274 /* From Unix-socket-FAQ: http://www.faqs.org/faqs/unix-faq/socket/ 276 /* From Unix-socket-FAQ: http://www.faqs.org/faqs/unix-faq/socket/
275 * 277 *
276 * If a UDP socket is unconnected, which is the normal state after a 278 * If a UDP socket is unconnected, which is the normal state after a
277 * bind() call, then send() or write() are not allowed, since no 279 * bind() call, then send() or write() are not allowed, since no
299 close(fd); 301 close(fd);
300 return -1; 302 return -1;
301 } /* if errno */ 303 } /* if errno */
302 } else { /* connect returns 0 */ 304 } else { /* connect returns 0 */
303 purple_debug(PURPLE_DEBUG_INFO, "QQ", "Connected.\n"); 305 purple_debug(PURPLE_DEBUG_INFO, "QQ", "Connected.\n");
304 fcntl(fd, F_SETFL, 0); 306 flags = fcntl(fd, F_GETFL);
307 fcntl(fd, F_SETFL, flags & ~O_NONBLOCK);
305 phb->func(phb->data, fd, NULL); 308 phb->func(phb->data, fd, NULL);
306 } 309 }
307 310
308 return fd; 311 return fd;
309 } 312 }