since it is posted under CodeBank - VISUAL BASIC .NET, so its clear that the class is written in VB.NET, however it still can be compiled as .NET component and be used in C++ or C# project.
To clarify what the functionalities of the class are and how it can be implemented into ur application:
----------------------------------------------------------------------------------
This class is made to have similar functionality with Winsock control in VB6. It provide the basic functions like Listen, Connect, Close, and also events like Connecting, Connected, DataArrival, IncomingConnection. However, it is not as complex as VB6 Winsock. Whoever has ever used VB6 Winsock control should have no problem using this class.
This class may be freely distributed and be used in any application. The user may also modify the original code and extend the functionalities.
To use the class just simply declare with WithEvents keyword. Declare one as client and another as server, they should reside in different applications or in the same one if required. Remember to declare an instance before using any of its members:
Dim WithEvents cServer as clsTCPSocket
Dim WithEvents cClient as clsTCPSocket
'the server must listen to an avalaible port before the client can connect
Private Sub btnListen_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnListen.Click
cServer.Listen(100)
End Sub
'to connect just simple call the connect function with the same port number as specified by server.
Private Sub btnConnect_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnConnect.Click
cClient.Connect("PCName", 100)
End Sub
Private Sub IncomingConnHandler() Handles cServer.IncomingConnection
cServer.Accept()
End Sub
to send data just call SendData function, the DataArrival event will be invoked when the data received.
can u please add index for every connection like this
Code:
Public Sub client_Connected(ByVal Index As Integer) Handles client.Connected
End Sub
to control between multiple connections ??
thanks for this amazing class
lol that is such a VB6 question. I haven't used this class but if the author wrote the events properly, I'd expect the event handler to have a sender argument which you can use to identify specific sockets.
C++ programmers will dismiss you as a cretinous simpleton for your inability to keep track of pointers chained 6 levels deep and Java programmers will pillory you for buying into the evils of Microsoft. Meanwhile C# programmers will get paid just a little bit more than you for writing exactly the same code and VB6 programmers will continue to whitter on about "footprints". - FunkyDexter
There's just no reason to use garbage like InputBox. - jmcilhinney
The threads I start are Niya and Olaf free zones. No arguing about the benefits of VB6 over .NET here please. Happiness must reign. - yereverluvinuncleber