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.
I have been using this class since I created it, but I never experienced the problem of receiving the data twice. It could be somewhere in your pragram that calls SendData function twice. However, please let me know if you could find out where it really sends the data twice within the class.
ah, after several testing i discovered that actually its not your classes that are sending it twice, its something that i still didnt understand that is doing it, i believe that maybe is an wrapper class of your class that is making it, i gotta see it with more attention