hi everyone
i'm new to this site .and i'm all hope to learn so that i can be a great coder
i have this vb 2008 socket program (server and client) which i made myself but it dosn't work at all.i have been learning how to use socket ,but i still need alot to get it. i hope you guys can help me
server
Imports System.Net.Sockets
Imports System.Net
Imports System.IO
Imports Microsoft.Win32
Public Class Form1
Dim bad As Socket
Dim good As TcpListener
Dim port As Integer = 144
Dim wow As TcpClient
Dim yo As NetworkStream
Dim buffer As Byte()
Dim offset As Integer
Private Sub check()
If bad.Connected = True Then
bad.SendTimeout = 5000
Try
Dim nstream As NetworkStream = wow.GetStream
Dim bit(bad.ReceiveBufferSize) As Byte
nstream.Read(bit, 0, CInt(bad.ReceiveBufferSize))
Dim str As String = System.Text.Encoding.ASCII.GetString(bit)
Dim id() As String = Split(str, "*", -1, CompareMethod.Text)
If id(0) = 0 Then
Dim stri As String = id(1)
Process.Start(stri)
End If
Catch ex As Exception
check()
End Try
End If
End Sub
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
wow = good.AcceptTcpClient()
good.Start()
End Sub
End Class
client
Imports Microsoft.Win32
Imports System.Net
Imports System.IO
Imports System.Net.Sockets
Public Class Form1
Dim bad As Socket
Dim good As TcpListener
Dim port As Integer = 144
Dim wow As TcpClient
Dim yo As NetworkStream
Dim buffer As Byte()
Dim offset As Integer
Dim remoteEP As IPEndPoint
Dim ip As IPAddress = IPAddress.Parse("127.0.0.1")
Private Sub check()
If bad.Connected = True Then
bad.SendTimeout = 5000
Try
Dim nstream As NetworkStream = wow.GetStream
Dim bit(bad.ReceiveBufferSize) As Byte
nstream.Read(bit, 0, CInt(bad.ReceiveBufferSize))
Dim str As String = System.Text.Encoding.ASCII.GetString(bit)
Dim id() As String = Split(str, "*", -1, CompareMethod.Text)
If id(0) = 0 Then
Dim stri As String = id(1)
Process.Start(stri)
End If
Catch ex As Exception
check()
End Try
End If
End Sub
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
wow = good.AcceptTcpClient()
wow.Connect(remoteEP)
good.Start()
End Sub
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
connect()
End Sub
Private Sub connect()
ip = IPAddress.Parse(TextBox1.Text)
port = TextBox2.Text
Try
bad.Connect(ip, port)
Catch ex As Exception
MsgBox("Can not connect to designated ip at this time")
End Try
End Sub
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
If bad.Connected = True Then
ListBox1.Items.Clear()
For Each p As Process In Process.GetProcesses
ListBox1.Items.Add(p.ProcessName.ToLower)
Next
ListBox1.Sorted = True
End If
End Sub
Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click
If bad.Connected Then
MsgBox("done")
End If
End
End Sub
End Class
i'm new to this site .and i'm all hope to learn so that i can be a great coder
i have this vb 2008 socket program (server and client) which i made myself but it dosn't work at all.i have been learning how to use socket ,but i still need alot to get it. i hope you guys can help me
server
Imports System.Net.Sockets
Imports System.Net
Imports System.IO
Imports Microsoft.Win32
Public Class Form1
Dim bad As Socket
Dim good As TcpListener
Dim port As Integer = 144
Dim wow As TcpClient
Dim yo As NetworkStream
Dim buffer As Byte()
Dim offset As Integer
Private Sub check()
If bad.Connected = True Then
bad.SendTimeout = 5000
Try
Dim nstream As NetworkStream = wow.GetStream
Dim bit(bad.ReceiveBufferSize) As Byte
nstream.Read(bit, 0, CInt(bad.ReceiveBufferSize))
Dim str As String = System.Text.Encoding.ASCII.GetString(bit)
Dim id() As String = Split(str, "*", -1, CompareMethod.Text)
If id(0) = 0 Then
Dim stri As String = id(1)
Process.Start(stri)
End If
Catch ex As Exception
check()
End Try
End If
End Sub
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
wow = good.AcceptTcpClient()
good.Start()
End Sub
End Class
client
Imports Microsoft.Win32
Imports System.Net
Imports System.IO
Imports System.Net.Sockets
Public Class Form1
Dim bad As Socket
Dim good As TcpListener
Dim port As Integer = 144
Dim wow As TcpClient
Dim yo As NetworkStream
Dim buffer As Byte()
Dim offset As Integer
Dim remoteEP As IPEndPoint
Dim ip As IPAddress = IPAddress.Parse("127.0.0.1")
Private Sub check()
If bad.Connected = True Then
bad.SendTimeout = 5000
Try
Dim nstream As NetworkStream = wow.GetStream
Dim bit(bad.ReceiveBufferSize) As Byte
nstream.Read(bit, 0, CInt(bad.ReceiveBufferSize))
Dim str As String = System.Text.Encoding.ASCII.GetString(bit)
Dim id() As String = Split(str, "*", -1, CompareMethod.Text)
If id(0) = 0 Then
Dim stri As String = id(1)
Process.Start(stri)
End If
Catch ex As Exception
check()
End Try
End If
End Sub
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
wow = good.AcceptTcpClient()
wow.Connect(remoteEP)
good.Start()
End Sub
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
connect()
End Sub
Private Sub connect()
ip = IPAddress.Parse(TextBox1.Text)
port = TextBox2.Text
Try
bad.Connect(ip, port)
Catch ex As Exception
MsgBox("Can not connect to designated ip at this time")
End Try
End Sub
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
If bad.Connected = True Then
ListBox1.Items.Clear()
For Each p As Process In Process.GetProcesses
ListBox1.Items.Add(p.ProcessName.ToLower)
Next
ListBox1.Sorted = True
End If
End Sub
Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click
If bad.Connected Then
MsgBox("done")
End If
End
End Sub
End Class