send with MSG_DONTWAIT and setrlimit in Windows

Started by
2 comments, last by Evil Steve 13 years, 8 months ago
I have a linux project but I want to change it to be a windows project.
I meet two probelm.

First, the windows'winsock does not have MSG_DONTWAIT. How do I transfer the code as below to windows syntax?

send( socket, buffer, length, MSG_DONTWAIT );

Second, which funcotion in windows map to the setrlimit function of linux?

struct rlimit rt;
rt.rlim_max = rt.rlim_cur = 50;
setrlimit( RLIMIT_NOFILE, &rt );
akira32 編程之家 Yahoohttp://tw.myblog.yahoo.com/akira32-akira32
Advertisement
First: You don't need the rlimit call. You can open more than 50 files anyway.

Second: The MSG_DONTWAIT option is equivalent to setting the socket in non-blocking mode for the duration of the call only. Thus, you can use ioctlsocket() in WinSock:

u_long iMode=1;ioctlsocket(Socket,FIONBIO,&iMode);


If you always pass MSG_DONTWAIT, it's more efficient to put the socket in nonblocking mode once, and leave it there.
enum Bool { True, False, FileNotFound };
Thanks!
Should I replace MSG_DONTWAIT with zero in windows?

send( socket, buffer, length, MSG_DONTWAIT );//linux
send( socket, buffer, length, 0 );//windows
akira32 編程之家 Yahoohttp://tw.myblog.yahoo.com/akira32-akira32
Quote:Original post by akira32
Thanks!
Should I replace MSG_DONTWAIT with zero in windows?
Yes.

This topic is closed to new replies.

Advertisement