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. C#
  4. Socket Retreive

Socket Retreive

Scheduled Pinned Locked Moved C#
helpcsharpcomsysadminquestion
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.
  • J Offline
    J Offline
    Jason Weibel
    wrote on last edited by
    #1

    I have an application that retrieves data from a socket. The process is periodically not returning any results. I have tried the following methods for connecting to the socket in an attempt to resolve the issue but have been unsuccessful. Is this a problem in my code or is it related to network issues? What can be done to better track this issue and resolved it? Code Option #1  Dim Client As System.Net.Sockets.TcpClient  Dim netStream As NetworkStream ''// SETUP CONNECTION  Client = New System.Net.Sockets.TcpClient  Client.NoDelay = False  Client.Connect(Switch.IPAddress, Switch.Port)  netStream = Client.GetStream() ''// Read Buffer  Do   numberOfBytesRead = netStream.Read(bytes, 0, uCVT.IntNulls(Client.ReceiveBufferSize))  Loop While netStream.DataAvailable ''// Close  If Not netStream Is Nothing Then netStream.Close()  If Not Client Is Nothing Then Client.Close() Code Option #2  Dim Socket As Socket ''// SETUP CONNECTION  Socket = New Socket(AddressFamily.InterNetwork,  SocketType.Stream, ProtocolType.Tcp)  Dim rEP As New  IPEndPoint(IPAddress.Parse(Switch.IPAddress),  Switch.Port)  Socket.Connect(rEP) ''// Read Buffer  Dim bytes(1024) As Byte  Dim bytesRec As Integer = Socket.Receive(bytes, 0,  Socket.Available, Net.Sockets.SocketFlags.None) ''// Close  If Not Socket Is Nothing Then Socket.Close() Thank you, Jason W.

    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