mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
* win32/win32.[ch] (rb_w32_read, rb_w32_write): new functions.
use recv() and send() when fd is socket. fixed: [ruby-dev:28694] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@10231 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
a0261afccd
commit
da617f7f79
3 changed files with 33 additions and 0 deletions
|
@ -1,3 +1,8 @@
|
|||
Thu Jun 8 14:00:02 2006 NAKAMURA Usaku <usa@ruby-lang.org>
|
||||
|
||||
* win32/win32.[ch] (rb_w32_read, rb_w32_write): new functions.
|
||||
use recv() and send() when fd is socket. fixed: [ruby-dev:28694]
|
||||
|
||||
Wed Jun 7 14:51:22 2006 NAKAMURA Usaku <usa@ruby-lang.org>
|
||||
|
||||
* win32/win32.c (errmap): add some winsock errors.
|
||||
|
|
|
@ -3861,6 +3861,30 @@ rb_w32_close(int fd)
|
|||
return 0;
|
||||
}
|
||||
|
||||
#undef read
|
||||
size_t
|
||||
rb_w32_read(int fd, void *buf, size_t size)
|
||||
{
|
||||
SOCKET sock = TO_SOCKET(fd);
|
||||
|
||||
if (!is_socket(sock))
|
||||
return read(fd, buf, size);
|
||||
else
|
||||
return rb_w32_recv(fd, buf, size, 0);
|
||||
}
|
||||
|
||||
#undef write
|
||||
size_t
|
||||
rb_w32_write(int fd, const void *buf, size_t size)
|
||||
{
|
||||
SOCKET sock = TO_SOCKET(fd);
|
||||
|
||||
if (!is_socket(sock))
|
||||
return write(fd, buf, size);
|
||||
else
|
||||
return rb_w32_send(fd, buf, size, 0);
|
||||
}
|
||||
|
||||
static int
|
||||
unixtime_to_filetime(time_t time, FILETIME *ft)
|
||||
{
|
||||
|
|
|
@ -108,6 +108,8 @@ extern DWORD rb_w32_osid(void);
|
|||
#define pipe(p) _pipe(p, 2048L, O_BINARY)
|
||||
#define close(h) rb_w32_close(h)
|
||||
#define fclose(f) rb_w32_fclose(f)
|
||||
#define read(f, b, s) rb_w32_read(f, b, s)
|
||||
#define write(f, b, s) rb_w32_write(f, b, s)
|
||||
#define getpid() rb_w32_getpid()
|
||||
#define sleep(x) rb_w32_Sleep((x)*1000)
|
||||
#define Sleep(msec) (void)rb_w32_Sleep(msec)
|
||||
|
@ -490,6 +492,8 @@ int rb_w32_putc(int, FILE*);
|
|||
int rb_w32_getc(FILE*);
|
||||
int rb_w32_close(int);
|
||||
int rb_w32_fclose(FILE*);
|
||||
size_t rb_w32_read(int, void *, size_t);
|
||||
size_t rb_w32_write(int, const void *, size_t);
|
||||
int rb_w32_utime(const char *, const struct utimbuf *);
|
||||
int WINAPI rb_w32_Sleep(unsigned long msec);
|
||||
|
||||
|
|
Loading…
Reference in a new issue