comparison src/win32/libc_interface.c @ 13778:cb2060acb34f

[gaim-migrate @ 16190] Added wrapper for send() so that errno is set correctly committer: Tailor Script <tailor@pidgin.im>
author Daniel Atallah <daniel.atallah@gmail.com>
date Thu, 18 May 2006 13:48:11 +0000
parents cf292e05a6cc
children
comparison
equal deleted inserted replaced
13777:a5bfc93b5309 13778:cb2060acb34f
283 /* fd is not a socket handle.. pass it off to read */ 283 /* fd is not a socket handle.. pass it off to read */
284 return read(fd, buf, size); 284 return read(fd, buf, size);
285 } 285 }
286 } 286 }
287 287
288 int wgaim_send(int fd, const void *buf, unsigned int size, int flags) {
289 int ret;
290
291 ret = send(fd, buf, size, flags);
292
293 if (ret == SOCKET_ERROR) {
294 errno = WSAGetLastError();
295 if(errno == WSAEWOULDBLOCK)
296 errno = EAGAIN;
297 return -1;
298 }
299 return ret;
300 }
301
288 int wgaim_write(int fd, const void *buf, unsigned int size) { 302 int wgaim_write(int fd, const void *buf, unsigned int size) {
289 int ret; 303
290 304 if(wgaim_is_socket(fd))
291 if(wgaim_is_socket(fd)) { 305 return wgaim_send(fd, buf, size, 0);
292 if((ret = send(fd, buf, size, 0)) == SOCKET_ERROR) { 306 else
293 errno = WSAGetLastError();
294 if(errno == WSAEWOULDBLOCK)
295 errno = EAGAIN;
296 return -1;
297 } else {
298 /* success */
299 return ret;
300 }
301 } else
302 return write(fd, buf, size); 307 return write(fd, buf, size);
303 } 308 }
304 309
305 int wgaim_recv(int fd, void *buf, size_t len, int flags) { 310 int wgaim_recv(int fd, void *buf, size_t len, int flags) {
306 int ret; 311 int ret;