Link to home
Start Free TrialLog in
Avatar of j99
j99

asked on

setsockopt: Type Of Service - How?

I am trying to set the Type of Service socket options in a Visual C++ 5.0 (MFC) program. I am utilizing WinNT 4.0, winsock 1.1 and the CSocket class. I am particularly interested in setting the Precedence of the message. Can this be done? Can this be done with winsock 2? Thanks.
Avatar of sudhirbrat
sudhirbrat

In the function CSocket::Send( const void* lpBuf, int nBufLen, int nFlags = 0 );, u can use a flag MSG_OOB(Send out-of-band data ). But it works only for stream sockets. This option is generally used to send urgent data.
                            or
In the SetSockOpt() function u can Disable the Nagle algorithm for send with flag TCP_NODELAY. This will increase the performance, but has negative impact on network performance.


Avatar of j99

ASKER

Thank you for your interest in this question. I realize now that I should have been more specific. I'm specifically curious whether or not this works:

setsockopt(aSocket, IPPROTO_IP, IP_TOS,
           (const char FAR *)&tos, len);

where you are setting the precedence level. The sources I've looked at are consistent in saying that WinSock 1.1 does not provide access to the TOS field in the IP header; however, it's not clear whether or not WinSock 2.0 will really let you set this or not.
ASKER CERTIFIED SOLUTION
Avatar of zingo
zingo

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of j99

ASKER

I've looked high and low for documentation on this question. The documentation that I encountered "seems to indicate," as you suggest, that one may set this value using WinSock 2 and not 1.1. Of particular concern is whether or not Microsoft's specific implementation will allow this. Since much of the existing software at this shop is dependent on WinSock 1.1 calls, changing to WinSock 2 is highly problematic. Given all that, I'm happy to pay well for hard knowledge and experience with this question (which I'm assuming you have) before I go shooting my mouth off to management, customers, etc. Thank you for your interest in this question.
Hmm, since you said you were going to shout at the management, I thought that I should look into it in more detail. And guess what I found? In winsock.h for WinSock 1.1, there is a definition "#define IP_TOS              8           /* set/get IP Type Of Service       */".
But there is no documentation on how to use it, so I assume that 0 is low prio and 7 is high. Feel free to try it out. I cant see why they havent documented this, but one reason could be that it is not implemented yet. So if I were you, I would verify it using an Ethernet analyzer. I hope you haven't done any shouting yet.

Avatar of j99

ASKER

Yep, utilizing IP_TOS does not work in 1.1. But does it work in WinSock 2?
Tricky question. I have not used it myself, but I have been told it should work in version 2. My source on this is involved in IP telephony development, so I really hope that he knows what he is talking about.