ReuseAddress and the Compact framework

  • Thread starter Thread starter afonso.ricardo
  • Start date Start date
Can you post a snippet of the problem code you are using to call setsockopt?

Peter
 
But of course...

This code was inspired by another post in this forum (credit were it's
due). Unfortunately the post didn't answer the question completely

Here it goes:

Invocation (SendSocket is a regular .NET Socket):

this.SetSocketOption(SendSocket.Handle, SocketOptionLevel.Socket,
SocketOptionName.ReuseAddress, 1) ;

(Wrapper function to call setsockopt Interop)
public int SetSocketOption(IntPtr m_Handle,SocketOptionLevel
optionLevel, SocketOptionName optionName, int optionValue)
{

return
setsockopt(
m_Handle,
optionLevel,
optionName,
ref optionValue,
Marshal.SizeOf(optionValue));
}

(setsockopt interop declaration)
[DllImport("Winsock",EntryPoint="setsockopt", CharSet=CharSet.Auto,
SetLastError=true)]
public extern static int setsockopt(IntPtr _sock, SocketOptionLevel
level, SocketOptionName name, ref int optionValue, int int_val);

Here it is...

Thanks in advance for your help.

Ricardo Afonso
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top