Skip to main content
GameDev.net gamedev.net
🔒 Locked

send with MSG_DONTWAIT and setrlimit in Windows

Started by akira32 Jul 29, 2010 at 3:04 AM 2 replies 15.4k views
Original Post
akira32
akira32
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
hplus0603
hplus0603
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 };
akira32
akira32
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
Evil Steve
Evil Steve
Quote:
Original post by akira32
Thanks!
Should I replace MSG_DONTWAIT with zero in windows?
Yes.

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.