|
|
||||||||||||||
![]() 渥太华华人网上社区 |
|
| 注册账号 | Blog | 论坛帮助 | 会员列表 | 搜索 | 今日新帖 | 标记版面已读 | 用户相册 |
![]() |
> 请教:如何将一个socket和一个文件handle联系起来? |
![]() |
|
|
主题工具 | 显示模式 |
|
[青铜长老]
ID: 350
|
If you can not use MFC classes and would like to make those things more portable, try using _fdopen. This IS supported in Windows api. But still, when you port this piece code to LINUX, make sure modify the code.
You can do like this in the header file: #define _fdopen fdopen OR You can modify your makefile and pass in pre-compiler options when on LINUX. likely say -DLINUX then in the code, you can write: #ifdefine LINUX fdopen(.....) #elif _fdopen(....) #endif |
|
|
|
[中级会员]
ID: 6834
|
thanks again chengchy! I tried and it does not work. It gives me the same error as using fdopen(). The problem is that in windows, the socket handle is different from the file handle. While in all other major OS, they are same. I will take your suggestion to try to wrap CSocketFile with directive definitions.
thanks, Nova |
|
|