Passing around winsock.

n3on

Member
Joined
Aug 29, 2005
Messages
5
Programming Experience
3-5
I am trying to make it so when winsock gets a dataarrival even it will send the sock to another function in a different module. For instance:

Private Sub Sock_DataArrival(ByVal sender As Object, ByVal e As AxMSWinsockLib.DMSWinsockControlEvents_DataArrivalEvent) Handles Sock.DataArrival
msgbox("1")
DataArrival(Sock)
msgbox("4")
End Sub


DataArrival(ByVal Sock As MSWinsockLib.Winsock)
msgbox("2")
Sock.getdata blah
msgbox("3")
End Function

But for some odd reason once it gets passed to DataArrival all hell breaks loose and the code quits moving. No error, no nothing. I added msgbox's to see where the code quits going and it won't even make it to 2. Any ideas?
 

jmcilhinney

VB.NET Forum Moderator
Staff member
Joined
Aug 17, 2004
Messages
14,717
Location
Sydney, Australia
Programming Experience
10+
Use the debugger. Set a breakpoint at the start of the first method and step through your code. You press F10 to step to next line in the current method or F11 to step into the next method or property on the current line.

I am wondering two things though. Is it necessary to pass this Winsock as an argument when it is a class-level variable? Is there a particular reason that you are using the old COM Winsock instead of the System.Net.Sockets namespace?
 

n3on

Member
Joined
Aug 29, 2005
Messages
5
Programming Experience
3-5
Heh, to tell you the truth I just assumed it was still the normal thing to use. I didn't mention this is my first day working with .net, moving from vb6. It is VERY frustrating knowing that I can write the same software in a matter of minutes in VB6 compared to what is taking me days in VB.NET. I suppose once I learn .net better I will be quicker then in vb6 right? Anyways, I am going to look into the newer sockets and learn how to use it. Thanks for letting me know! I could of been stuck using mswinsock.ocx for who knows how long.
 

jmcilhinney

VB.NET Forum Moderator
Staff member
Joined
Aug 17, 2004
Messages
14,717
Location
Sydney, Australia
Programming Experience
10+
I would strongly suggest dowloading the 101 VB.NET samples, which contains an example of using sockets and many other useful things. There's a link to the download site here.
 
Top Bottom