okay i wrote this up pretty quick cause i saw that other post about making a open source one so i wrote this in like 10 min :P
its only the client if you guys like ill write the Server Aswell
i will not include downloads ill just post pure source
It includes events, anti crashing, reconnect if connection fails and properties
The Source is Not Commented on but it is only VB.NET
if you want to see more shit like this say so i can code this shit in VB.NET and C# just send me a pm or reply
Code:
'Credits To DeToX <--Thats Me
'Fast Simple Socket System Open Source
'Please Include Credits
'DocketClass
Imports System.Threading, System.Net, System.IO, System.Net.Sockets
Public Class Client
#Region "Declarations"
Dim TcpClient As New TcpClient()
Dim Remote_IP As String = vbNull
Dim Remote_Port As Int32 = vbNull
Public Event RecievedData(ByVal Data As String)
Public Event FailToConnect(ByVal Reason As String)
#End Region
#Region "Main Code"
Sub New(ByVal IP As String, ByVal Port As Int32)
Remote_IP = IP
Remote_Port = Port
End Sub
Sub Connect()
Try
TcpClien*****nnect(Remote_IP, Remote_Port)
TcpClient.GetStream().BeginRead(New Byte() {0}, 0, 0, AddressOf Recieve, Nothing)
Catch ex As Exception
Thread.Sleep(4000)
RaiseEvent FailToConnect("Error Connecting To Host")
Connect()
End Try
End Sub
Sub Recieve(ByVal Ar As IAsyncResult)
Try
Dim Reader As New StreamReader(TcpClient.GetStream())
RaiseEvent RecievedData(Reader.ReadLine())
TcpClient.GetStream().BeginRead(New Byte() {0}, 0, 0, AddressOf Recieve, Nothing)
Catch ex As Exception
Thread.Sleep(4000)
RaiseEvent FailToConnect("Error Reading Data From Host")
Connect()
End Try
End Sub
Sub SendData(ByVal Data As String)
Try
Dim Writer As New StreamWriter(TcpClient.GetStream())
Writer.WriteLine(Data)
Writer.Flush()
Catch ex As Exception
Thread.Sleep(4000)
RaiseEvent FailToConnect("Error Sending Data To Host")
Connect()
End Try
End Sub
#End Region
#Region "Properties"
Private ReadOnly Property BufferSize
Get
Return TcpClient.ReceiveBufferSize()
End Get
End Property
Private ReadOnly Property Connected
Get
Return TcpClien*****nnected
End Get
End Property
Private ReadOnly Property Available
Get
Return TcpClient.Available
End Get
End Property
#End Region
End Class