Socket Exception Please Help....

R

Rik

Hello Experts,
I have a communication server in VB.NET.
It was working fine from last 6 months, but now start giving error message
like that.

21-03-2005 07:58:27 DoListenSystem.Net.Sockets.SocketException: A blocking
operation was interrupted by a call to WSACancelBlockingCall
at System.Net.Sockets.Socket.Accept()
at System.Net.Sockets.TcpListener.AcceptTcpClient()
at ProjectCommServer.CommServer.DoListen()

When I launched it I got that error message in my error log file..
Can anybody tell me what sort of that error is? and why is that keep coming
in now?

Thanks in Advance....
Please help....

Rik
 
R

Rik

Hi Tom,
Thanks for your feed back.
here is code where I am getting that error message.

Private Sub DoListen()

Try

' Listen for new connections.

listener = New TcpListener(System.Net.IPAddress.Any, PORT_NUM)

listener.Start()

Do

' Create a new user connection using TcpClient returned by

' TcpListener.AcceptTcpClient()

Dim client As New UserConnection(listener.AcceptTcpClient)



' Create an event handler to allow the UserConnection to communicate

' with the window.

AddHandler client.LineReceived, AddressOf OnLineReceived

UpdateStatus("(" & Format(DateTime.Now, "dd-MM-yyyy HH:mm:ss") & ")." & "New
Connection Found: Waiting for Log-in")

Loop Until False

Catch ex As Exception

Call WritetoTextFileMain("DoListen" & ex.ToString)



End Try

End Sub

*When ever I start my Application , I got that Error message...

Please help meeeeee

Rik
 
T

Tom Shelton

Hi Tom,
Thanks for your feed back.
here is code where I am getting that error message.

Private Sub DoListen()

Try

' Listen for new connections.

listener = New TcpListener(System.Net.IPAddress.Any, PORT_NUM)

listener.Start()

Do

' Create a new user connection using TcpClient returned by

' TcpListener.AcceptTcpClient()

Dim client As New UserConnection(listener.AcceptTcpClient)



' Create an event handler to allow the UserConnection to communicate

' with the window.

AddHandler client.LineReceived, AddressOf OnLineReceived

UpdateStatus("(" & Format(DateTime.Now, "dd-MM-yyyy HH:mm:ss") & ")." & "New
Connection Found: Waiting for Log-in")

Loop Until False

Catch ex As Exception

Call WritetoTextFileMain("DoListen" & ex.ToString)



End Try

End Sub

*When ever I start my Application , I got that Error message...

Please help meeeeee

Rik

Hmmm, nothing jumps out at me as obviously wrong here... Have you
debuged this and found exactly what line is throwing the exception?
Most likely it's the listener.AcceptTcpClient line.

I don't normally use the tcpclient or tcplistner stuff. I almost always
use the the System.Net.Socket class using the async mode of operation.
I just saw you asking for help, so I thought I'd take a stab at it :)
 
R

Rik

Hi Tom,

I think I figured out why this error is appearing.
I am also using the Async menthod, but I am Locking the Stream to avoid any
conflictions.
That error only appears when I lauch the Two Instances of the same
aplication but on the differant ports, they both try to Lock the Streams at
the same time, which are causing a conflict.
Now what I did that I am running the Two application with single AppDomain,
I mean running a second instance from the Main AppDomian thread.
Which helps me to keep the second comms request in the main threading pool
as well.

are you suggesting that TCPClients are not best as compared to
System.net.sockets?

Cheers for your help

Rik
 
T

Tom Shelton

Hi Tom,

I think I figured out why this error is appearing.
I am also using the Async menthod, but I am Locking the Stream to avoid any
conflictions.
That error only appears when I lauch the Two Instances of the same
aplication but on the differant ports, they both try to Lock the Streams at
the same time, which are causing a conflict.
Now what I did that I am running the Two application with single AppDomain,
I mean running a second instance from the Main AppDomian thread.
Which helps me to keep the second comms request in the main threading pool
as well.

are you suggesting that TCPClients are not best as compared to
System.net.sockets?

No... I'm not really suggesting anything. I just prefere to use the raw
socket class. It's closer to the way I am used to doing things. Even
if VB6 I never used to use 3rd party socket components or the winsock
control. I used to use the winsock32 api... The socket class is a
fairly thin wrapper :)

Cheers for your help

You're welcome - though I didn't do anything really :)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top