Results 1 to 7 of 7

Thread: TCP Socket class

  1. #1

    Thread Starter
    Member
    Join Date
    May 2003
    Posts
    58

    TCP Socket class

    Just a simple working class for maintaining client server application using TCP connection. Hopefully it is usefull for u guys....
    Attached Files Attached Files

  2. #2

    Thread Starter
    Member
    Join Date
    May 2003
    Posts
    58
    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.

  3. #3
    yay gay PT Exorcist's Avatar
    Join Date
    Apr 2002
    Location
    . . . my reason of shame
    Posts
    2,729
    thanks ill try it and if i find it bugless then ill use it
    \m/\m/

  4. #4
    yay gay PT Exorcist's Avatar
    Join Date
    Apr 2002
    Location
    . . . my reason of shame
    Posts
    2,729
    ok as i dont like vb.net i am translating this to C#

    edit: damn you vb.net programmers why have u to use the redim? grrr
    Last edited by PT Exorcist; Oct 2nd, 2003 at 04:37 PM.
    \m/\m/

  5. #5
    yay gay PT Exorcist's Avatar
    Join Date
    Apr 2002
    Location
    . . . my reason of shame
    Posts
    2,729
    is it my impression or does this class send everything twice?
    \m/\m/

  6. #6

    Thread Starter
    Member
    Join Date
    May 2003
    Posts
    58
    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.

  7. #7
    yay gay PT Exorcist's Avatar
    Join Date
    Apr 2002
    Location
    . . . my reason of shame
    Posts
    2,729
    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

    thanks by the answer
    \m/\m/

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width