PDA

Click to See Complete Forum and Search --> : Accepting Winsock by Sockets.Socket


Jhd.Honza
Aug 19th, 2004, 08:33 AM
Hi, I have VB5 application with winsock, which tries to connect to my C# server.

If I use AcceptTcpClient(), AcceptSocket() or Accept(), VB still says it's winsock is in CONNECTING state. What should I do with the Socket to accept the winsock connection?

I can use send and receive functions, but no DataArrival event occurs.

Mike Hildner
Aug 20th, 2004, 03:46 PM
Accept should work, although I've only used the asynchronous BeginAccept. Are you calling Socket.Listen before Socket.Accept?

Jhd.Honza
Aug 23rd, 2004, 04:05 AM
hmm I've found out it works, but the applications need to be in run mode, if I try to debug the code step by step, it does not connect.

I just asked for any special tasks to make connecting winsock connected, but it seems there aren't any.

Is there any way how to debug the code? Or why it doesn't work?

Mike Hildner
Aug 23rd, 2004, 08:56 AM
If you're using the .Accept method, and run your code through the point to execute that line of code, .Accept will block until a connection is accepted. Not sure if that helps or not, but also not sure what your code looks like.

Jhd.Honza
Aug 23rd, 2004, 01:36 PM
Well .NET blocks after reaching .Accept, which si ok since I run it in a new thread.

On the client side, there is a VB code similar to this one:


Winsock1.Connect
Do
Doevents
Loop Until Winsock1.State = sckConnected


If I debug this code, Connect event is never faired having the winsock at sckConnecting, although .Accept method on the .NET succesfully finishes.
However, if I run this code and set up a breakpoint on the Connect event, it works.

Mike Hildner
Aug 23rd, 2004, 02:08 PM
Wish I could help, but I have no idea, don't even mess around with "Classic" VB anymore. Maybe posting in that forum might get you an answer.