Chat Client error

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • abarnes@nc.rr.com

    #1

    Chat Client error

    I am getting an error after running a chat client/server app for a few
    hours - Operation is not allowed on non-connected sockets. Once I
    start up the server and all the clients(only 3 at this point), things
    run smoothly for a while. The error is showing up at the server, but,
    seems to be b/c the client's tcpclient is no longer listening. The
    tcpclient is connected the whole time, named _client. Here is the send
    from the server and client where things to be crashing:

    Server Send:

    Public Sub SendMessage(ByV al message As String)
    Try
    Dim ns As System.Net.Sock ets.NetworkStre am

    SyncLock _client.GetStre am
    ns = _client.GetStre am
    Dim bytesToSend As Byte() =
    System.Text.Enc oding.ASCII.Get Bytes(message)
    ns.Write(bytesT oSend, 0, bytesToSend.Len gth)
    ns.Flush()
    End SyncLock

    Catch ex As Exception
    Console.WriteLi ne(ex.ToString)
    End Try
    End Sub

Working...