TCP Socket Class

Cyrus

Member
Joined
Jul 25, 2003
Messages
11
Im trying to develop a full TCP Class which should be comparable to the Winsock Component of VB6.0

But it should also be able to handle multiple incoming and outgoing TCP connections.

this Class (see attachment) does everything I want, but i think its not a very "beautiful code". Has someone suggestions? If you improve my Class then please send me back a copy of it, thank you!


How does this Class work?

Example how to set up a TCP Server:

Code:
  Public TCP As New cTCPServer(10)

  Private Sub DataArrival(ByVal ID As Integer, ByVal Data As String)
    ID = ConnectionID
    Data = Incoming Data
  End Sub

  Private Sub ConnectionState(ByVal ID As Integer, ByVal State As Integer)
    ID = ConnectionID
    State = Connection Status (Just connected, Just disconnected, ...)
  End Sub


  Sub Main()
    AddHandler TCP.DataArrival, AddressOf DataArrival
    AddHandler TCP.ConnectionState, AddressOf ConnectionState
    TCP.Listen(1000)

    ...
  End Sub

You can connect to a TCP Server by simply calling

Code:
intID = TCP.Connect("www.microsoft.com", 80)

ConnectionIDs are used to identify a specific connection. Every incoming and outgoing connection has a unique ID.

Again, please send me back improvements, thanks!

Cyrus
 

Attachments

Back
Top