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. .Net Sockets

.Net Sockets

Scheduled Pinned Locked Moved Visual Basic
csharpcomsysadminhelpquestion
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'm working on a socket program using .net and going against a Unix server. The delays in the following code are needed for it to work correctly. Can anyone help me find a way to get this working without adding the delay? Friend Function Insert(ByVal Name As String, ByVal Client As System.Net.Sockets.TcpClient, ByVal netStream As NetworkStream, ByVal sr As StreamWriter) As String    Dim InsertRequest As String = "INSERT::" & Name & ";"    Dim sendInsertRequest As [Byte]() = Encoding.ASCII.GetBytes(InsertRequest)    ''// Submit Insert Request    sr.WriteLine("CMD-" & vbTab & InsertRequest)    netStream.Write(sendInsertRequest, 0, sendInsertRequest.Length)    ''// Get Response    Dim Response As String = GetResponse(Client, netStream, sr)    Return Response End Function Private Function GetResponse(ByVal Client As System.Net.Sockets.TcpClient, ByVal netStream As NetworkStream, ByVal sr As StreamWriter) As String    ''// Add Delay    System.Threading.Thread.Sleep(m_delay)    ''// Read Buffer and Write to Open File    Dim numberOfBytesRead As Integer = 0    Dim bytes(Client.ReceiveBufferSize) As Byte    Dim returndata As String = Encoding.ASCII.GetString(bytes)    Dim SocketData As New System.Text.StringBuilder    Do      numberOfBytesRead = netStream.Read(bytes, 0, uCVT.IntNulls(Client.ReceiveBufferSize))      returndata = Encoding.ASCII.GetString(bytes)      returndata = Microsoft.VisualBasic.Left(returndata, numberOfBytesRead)      SocketData.Append(returndata)      System.Threading.Thread.Sleep(m_delay)    Loop While netStream.DataAvailable    sr.WriteLine("RSP-" & vbTab & SocketData.ToString)    Return SocketData.ToString End Function 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