How to create a SocketType.Seqpacket Listening Socket?

  • Thread starter Thread starter Vladimir Lushnikov
  • Start date Start date
V

Vladimir Lushnikov

Hi,

I'm experimenting with the Seqpacket protocol, because the
connectionless protocols aren't enough for my needs, and TCP/IP doesn't
preserve message boundaries.

This is what I've currently got in C#
--------------------------------------------------------------------------
listeningSock = new Socket(AddressFamily.InterNetwork,
SocketType.Seqpacket, ProtocolType.Unknown);

// Bind to the local IP Address
listeningSock.Bind(ipLocal);

// Start listening
// WARNING - ONLY 10
listeningSock.Listen(10);

// Now begin receiving connections
listeningSock.BeginAccept(new
AsyncCallback(OnConnectionRequest), null);
--------------------------------------------------------------------------

Now that throws a SocketException at the constructor:

--------------------------------------------------------------------------
System.Net.Sockets.SocketException was unhandled
Message="An address incompatible with the requested protocol was
used"
Source="System"
ErrorCode=10047
NativeErrorCode=10047
StackTrace:
at System.Net.Sockets.Socket..ctor(AddressFamily addressFamily,
SocketType socketType, ProtocolType protocolType)

at clsServClientColClass..ctor(Int32 portNum)

at SimpleAsyncServ.frmMainSimpServ.frmMainSimpServ_Load(Object
sender, EventArgs e)

at System.Windows.Forms.Form.OnLoad(EventArgs e)

at System.Windows.Forms.Form.OnCreateControl()

at System.Windows.Forms.Control.CreateControl(Boolean
fIgnoreVisible)

at System.Windows.Forms.Control.CreateControl()

at System.Windows.Forms.Control.WmShowWindow(Message& m)

at System.Windows.Forms.Control.WndProc(Message& m)

at System.Windows.Forms.ScrollableControl.WndProc(Message& m)

at System.Windows.Forms.ContainerControl.WndProc(Message& m)

at System.Windows.Forms.Form.WmShowWindow(Message& m)

at System.Windows.Forms.Form.WndProc(Message& m)

at
System.Windows.Forms.Control.ControlNativeWindow.OnMessage(Message& m)

at
System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m)

at System.Windows.Forms.NativeWindow.DebuggableCallback(IntPtr
hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)

at System.Windows.Forms.SafeNativeMethods.ShowWindow(HandleRef
hWnd, Int32 nCmdShow)

at System.Windows.Forms.Control.SetVisibleCore(Boolean value)

at System.Windows.Forms.Form.SetVisibleCore(Boolean value)

at System.Windows.Forms.Control.set_Visible(Boolean value)

at
System.Windows.Forms.Application.ThreadContext.RunMessageLoopInner(Int32
reason, ApplicationContext context)

at
System.Windows.Forms.Application.ThreadContext.RunMessageLoop(Int32
reason, ApplicationContext context)

at System.Windows.Forms.Application.Run(Form mainForm)

at SimpleAsyncServ.Program.Main()

at System.AppDomain.nExecuteAssembly(Assembly assembly, String[]
args)

at System.AppDomain.ExecuteAssembly(String assemblyFile,
Evidence assemblySecurity, String[] args)

at
Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly()

at System.Threading.ThreadHelper.ThreadStart_Context(Object
state)

at System.Threading.ExecutionContext.Run(ExecutionContext
executionContext, ContextCallback callback, Object state)

at System.Threading.ThreadHelper.ThreadStart()
--------------------------------------------------------------------------


I'm completely not sure on what protocol type it is supposed to use,
and I've heard the SocketType.Seqpacket uses the SCTP protocol, which
means that the address family must be InternetWork


Thanks for help,
Vladimir Lushnikov
 
Back
Top