Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. Visual Basic
  4. ioctlSocket in VB.NET

ioctlSocket in VB.NET

Scheduled Pinned Locked Moved Visual Basic
csharpdesignhelpquestion
1 Posts 1 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • A Offline
    A Offline
    Abel
    wrote on last edited by
    #1

    Hello everybody. I want to use the ioctlsocket winsock function to set non blocking mode to a socket in VB.NET. I have to use this function because it seems there is no means to create a Net.sockets.socket object from a valid Win32 SOCKET handle (provided by a custom function librairy) In my code, I alway Have SOCKET_ERROR after ioctlsocket call ... and lastError is set to 10022 Maybe my FIONBIO constant is not correct. Can someone help me ? tks // C Computing of FIONBIO : //#define IOCPARM_MASK 0x7f /*parameters must be < 128 bytes */ //#define IOC_IN 0x80000000 /* copy in parameters */ //#define _IOW(x,y,t) (IOC_IN|(((long)sizeof(t)&IOCPARM_MASK)<<16)|((x)<<8)|(y)) //#define FIONBIO _IOW('f', 126, u_long) /* set/clear non-blocking i/o */ Private Shared ul As IntPtr = Marshal.AllocHGlobal(4) Private Declare Function ioctlsocket Lib "ws2_32.dll" (ByVal sck As Long, ByVal cmd As Long, <[In](), Out()> ByVal argp As IntPtr) As Integer Public Shared Sub SetNonBlockingMode(ByVal sck As Long) 'Dim ui As UInt32 = UInt32.Parse(1) 'Marshal.StructureToPtr(ui, ul, False) Marshal.WriteInt32(ul, 0) LastErrorValue = 0 Dim iRes As Long = ioctlsocket(sck, 2147772030, ul) 'Valeur de FIONBIO sur mon PC = 2147772030 If iRes = SOCKET_ERROR Then LastErrorValue = Marshal.GetLastWin32Error() Throw New Net.Sockets.SocketException(LastErrorValue) End If End Sub

    1 Reply Last reply
    0
    Reply
    • Reply as topic
    Log in to reply
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes


    • Login

    • Don't have an account? Register

    • Login or register to search.
    • First post
      Last post
    0
    • Categories
    • Recent
    • Tags
    • Popular
    • World
    • Users
    • Groups