Click here to Skip to main content
16,018,234 members
Home / Discussions / Visual Basic
   

Visual Basic

 
GeneralRe: SystemParametersInfo Pin
rlx5007-Jul-05 7:59
rlx5007-Jul-05 7:59 
GeneralRe: SystemParametersInfo Pin
Anonymous7-Jul-05 16:23
Anonymous7-Jul-05 16:23 
Generalcontrol on word save prompt msg Pin
paykani2-Jul-05 19:28
paykani2-Jul-05 19:28 
Generalip address Pin
Binary01102-Jul-05 16:52
Binary01102-Jul-05 16:52 
GeneralRe: ip address Pin
Mohamed Ishak2-Jul-05 19:23
professionalMohamed Ishak2-Jul-05 19:23 
GeneralListView open folder path Pin
Algera2-Jul-05 10:35
sussAlgera2-Jul-05 10:35 
GeneralRe: ListView open folder path Pin
Anonymous6-Jul-05 7:16
Anonymous6-Jul-05 7:16 
Generalhelp on socket programming in vb.net Pin
boy2122-Jul-05 7:48
boy2122-Jul-05 7:48 
pls help me. i wonder why my server cannot send a message to my client and my client cannot read from server. anyone pls help me to debug or give me tip to do it by showing wats the command to write.My deadline for this project is comong soon. Pls help me. thanks a lot.

here is my source code


server:

Imports System.Net
Imports System.Net.Sockets
Imports System.Threading
Imports System.IO
Imports System.Text
Public Class Form1
Inherits System.Windows.Forms.Form
Private Client As TcpClient
Private Listener As Socket
Private RemotePort As Integer = 1337
Private RemoteHost As String = "localhost"
Dim add As IPAddress = IPAddress.Parse("220.255.41.189")
Public Shared Connected As New ManualResetEvent(False)


#End Region

Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load

End Sub

Private Sub blisten_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles blisten.Click

Listener = New Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp)
Listener.Blocking = False
Listener.Bind(New IPEndPoint(add, RemotePort))
Listener.Listen(1)

ListBox1.Items.Add("Waiting for connection...")

Listener.BeginAccept(New AsyncCallback(AddressOf AcceptConnection), Listener)
End Sub
Public Sub AcceptConnection(ByVal ar As IAsyncResult)
ListBox1.Items.Add("Connection established.")
Connected.Set()

Dim serverSock As Socket = CType(ar.AsyncState, Socket)
Dim clientSock As Socket = serverSock.EndAccept(ar)
Dim buffer(1024) As Byte

While True
If (clientSock.Poll(100, SelectMode.SelectRead)) Then
Dim count As Integer = clientSock.Receive(buffer)
ListBox1.Items.Add(System.Text.Encoding.ASCII.GetString(buffer, 0, count))
End If
End While
End Sub



Private Sub bsend_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles bsend.Click
Dim Stream As NetworkStream = Client.GetStream()
Dim dataSend As [Byte]() = System.Text.Encoding.ASCII.GetBytes(TextBox1.Text)
'Send Message
Stream.Write(dataSend, 0, dataSend.Length)

Stream.Flush()
End Sub
End Class





my client source code:


Imports System.Net
Imports System.Net.Sockets
Imports System.Threading
Imports System.IO
Imports System.Text
Public Class Form1
Inherits System.Windows.Forms.Form
Private Client As TcpClient
Private Listener As Socket
Private RemotePort As Integer = 1337
Private RemoteHost As String = "localhost"
Dim add As IPAddress = IPAddress.Parse("220.255.41.189")
Public Shared Connected As New ManualResetEvent(False)


Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load

End Sub


Private Sub bconnect_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles bconnect.Click
Try
Client = New TcpClient
Client.Connect(add, RemotePort)
Catch ex As Exception
ListBox1.Items.Add("No route to host.")
End Try
End Sub

Private Sub bsend_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles bsend.Click
Dim Stream As NetworkStream = Client.GetStream()
Dim dataSend As [Byte]() = System.Text.Encoding.ASCII.GetBytes(TextBox1.Text)
'Send Message
Stream.Write(dataSend, 0, dataSend.Length)

Stream.Flush()
End Sub
Public Sub AcceptConnection(ByVal ar As IAsyncResult)
ListBox1.Items.Add("Connection established.")
Connected.Set()

Dim serverSock As Socket = CType(ar.AsyncState, Socket)
Dim clientSock As Socket = serverSock.EndAccept(ar)
Dim buffer(1024) As Byte

While True
If (clientSock.Poll(100, SelectMode.SelectRead)) Then
Dim count As Integer = clientSock.Receive(buffer)
ListBox1.Items.Add(System.Text.Encoding.ASCII.GetString(buffer, 0, count))
End If
End While
End Sub

GeneralRe: help on socket programming in vb.net Pin
Mohamed Ishak2-Jul-05 19:29
professionalMohamed Ishak2-Jul-05 19:29 
QuestionAnybody has the TAPI SDK for Win2K? Pin
Member 20898122-Jul-05 0:52
Member 20898122-Jul-05 0:52 
AnswerRe: Anybody has the TAPI SDK for Win2K? Pin
Dave Kreskowiak2-Jul-05 11:21
mveDave Kreskowiak2-Jul-05 11:21 
GeneralRe: Anybody has the TAPI SDK for Win2K? Pin
Member 208981212-Jul-05 8:49
Member 208981212-Jul-05 8:49 
GeneralRe: Anybody has the TAPI SDK for Win2K? Pin
Dave Kreskowiak12-Jul-05 11:53
mveDave Kreskowiak12-Jul-05 11:53 
QuestionHow to populate list view Pin
kalyan.n@dsolusys.com1-Jul-05 18:51
kalyan.n@dsolusys.com1-Jul-05 18:51 
AnswerRe: How to populate list view Pin
Christian Graus1-Jul-05 20:36
protectorChristian Graus1-Jul-05 20:36 
GeneralRe: How to populate list view Pin
kalyan.n@dsolusys.com1-Jul-05 21:52
kalyan.n@dsolusys.com1-Jul-05 21:52 
GeneralRe: How to populate list view Pin
Christian Graus1-Jul-05 22:01
protectorChristian Graus1-Jul-05 22:01 
GeneralRe: How to populate list view Pin
kalyan.n@dsolusys.com2-Jul-05 0:33
kalyan.n@dsolusys.com2-Jul-05 0:33 
GeneralRe: How to populate list view Pin
S. Senthil Kumar2-Jul-05 0:40
S. Senthil Kumar2-Jul-05 0:40 
GeneralRe: How to populate list view Pin
Anonymous2-Jul-05 20:36
Anonymous2-Jul-05 20:36 
GeneralLittle help Pin
Anonymous1-Jul-05 15:27
Anonymous1-Jul-05 15:27 
GeneralRe: Little help Pin
Christian Graus1-Jul-05 20:29
protectorChristian Graus1-Jul-05 20:29 
Generalfile & folder search with vb.net 2003 Pin
JimClark681-Jul-05 7:20
JimClark681-Jul-05 7:20 
GeneralRe: file & folder search with vb.net 2003 Pin
cynferdd1-Jul-05 7:57
cynferdd1-Jul-05 7:57 
Questionhow to disable events in treeview Pin
aimar_201-Jul-05 4:42
aimar_201-Jul-05 4:42 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.