00001 #ifndef __WIN32_STREAMS_H
00002 #define __WIN32_STREAMS_H
00003
00004 #include <winsock2.h>
00005
00006 extern "C" {
00007 int close(int fd);
00008 int read(int fd, void *buf, size_t count);
00009 int write(int fd, const void *buf, size_t count);
00010
00011 unsigned int sleep(unsigned int seconds);
00012 }
00013
00014 #ifndef __GNUC__
00015
00016
00017
00018 #define __STDC__ 1 // prevents io.h from dllimporting close/read/write
00019
00020 #endif
00021
00022 #include <io.h>
00023
00024 struct socket_fd_pair
00025 {
00026 SOCKET socket;
00027 int fd;
00028 };
00029
00030 class SocketFromFDMaker
00031 {
00032 protected:
00033 HANDLE m_hThread;
00034 socket_fd_pair m_pair;
00035 SOCKET m_socket;
00036 bool m_wait;
00037 public:
00038 SocketFromFDMaker(int fd, LPTHREAD_START_ROUTINE lpt,
00039 bool wait_for_termination = false);
00040 ~SocketFromFDMaker();
00041 SOCKET GetSocket() { return m_socket; }
00042 };
00043
00044 DWORD WINAPI fd2socket_fwd(LPVOID lpThreadParameter);
00045 DWORD WINAPI socket2fd_fwd(LPVOID lpThreadParameter);
00046
00047 #endif // __WIN32_STREAMS_H