Windows Socket

bojanv55

Newcomer
Joined
Dec 31, 1969
Messages
2
Location
Podgorica, Yugoslavia
In VB 6.0 I used to add Windows socket control 6.0 (mswinsock.ocx) to my project, and than i could make programs for internet and betwork. Now , in VB.NET i can't find this control. Do i have to use something else instead of this? Like system.net.sockets or something like that. And where to find manual on using it?
 
You will use either the Socket or TclClient (which wraps Socket) classes in .NET to achieve this. There is at least one example in the framework sdk, and loads around on the internet. The help is, as always, a good reference too.

It's a fair jump from the winsock control to the Socket class, but with enough examples it isn't too difficult.
 
I have the same problem. I was using the Winsock control in VB6 and have now upgraded to VS.Net. The problem I have found is that in all the code samples, the calls to recieve appear to block.

Using the VB6 control, my app used the same port to send and recieve UDP packets to whichever IP address I chose whether the other end was listening or not and just waited for the DataRecieved message. The recipient always sent an acknowledgement when a msg was recieved as a kind of handshake. I don't see how I can achieve the same thing in .Net. certainly not without far more research & coding.
 
You can achieve this with thread in which you can read Pending property of TCPServer class and raise an event. Also,
DataAvailable property of Stream (TcpClient.GetStream) shows you if there is data in recieve buffer. Best manual is MSDN Library.
 
Thanks but I already solved that problem in a similar way to what you described.

I ended up putting the listening call inside a loop which was called from a thread. As you sugested, I used RaiseEvent when a message was recieved.

As my previous post mentioned, I have upgraded from Visual Studio 6 where I dont believe free threading existed so it took some investigating but I got there in the end :-)
 
Back
Top