Socket Multiple Connection VB.NET
Socket Multiple Connection VB.NET
Socket Multiple Connection VB.NET
Socket Multiple Connection VB.NET
Socket Multiple Connection VB.NET
Socket Multiple Connection VB.NET Socket Multiple Connection VB.NET Socket Multiple Connection VB.NET Socket Multiple Connection VB.NET Socket Multiple Connection VB.NET Socket Multiple Connection VB.NET Socket Multiple Connection VB.NET Socket Multiple Connection VB.NET
Socket Multiple Connection VB.NET Socket Multiple Connection VB.NET
Socket Multiple Connection VB.NET
Go Back  Xtreme Visual Basic Talk > > > Socket Multiple Connection VB.NET


Reply
 
Thread Tools Display Modes
  #1  
Old 09-24-2013, 01:10 AM
eawedat eawedat is offline
Newcomer
 
Join Date: Mar 2012
Posts: 8
Default Socket Multiple Connection VB.NET


hey all,

I wish to send message to multiple computers (LAN network).

each computer in lab is running the server except one computer which is the client.

Problem : once message has been sent to first computer , the client stops to send to other computers.

CLIENT :


Code:
Dim ip As String
Dim i As Integer
Dim serverStream As NetworkStream
Dim outStream As Byte()

Dim counter As Integer = 0
For i = 0 To 100

Try
ip = txtRange.Text & i

clientSocket.Connect(ip, 8888)

If clientSocket.Connected = True Then

serverStream = clientSocket.GetStream()
outStream = System.Text.Encoding.ASCII.GetBytes("Message from the client$")
serverStream.Write(outStream, 0, outStream.Length)
serverStream.Flush()

End If

Catch ex As Exception
End Try
Next
SERVER:


Code:
Dim serverSocket As New TcpListener(8888)
Dim requestCount As Integer
Dim clientSocket As TcpClient
serverSocket.Start()
clientSocket = serverSocket.AcceptTcpClient()

While (true)

Dim networkStream As NetworkStream = clientSocket.GetStream()
Dim bytesFrom(10024) As Byte
networkStream.Read(bytesFrom, 0, CInt(clientSocket.ReceiveBufferSize))
Dim dataFromClient As String = System.Text.Encoding.ASCII.GetString(bytesFrom)
dataFromClient = dataFromClient.Substring(0, dataFromClient.IndexOf("$"))
MessageBox.Show("Data from client -  " + dataFromClient)
End While


clientSocket.Close()
serverSocket.Stop()
thank you.
Reply With Quote
  #2  
Old 09-24-2013, 07:46 AM
passel's Avatar
passelSocket Multiple Connection VB.NET passel is offline
Sinecure Expert

Super Moderator
* Guru *
 
Join Date: Jun 2003
Location: Upstate New York, usa
Posts: 8,023
Default

Do you have to use TCP?
It would seem using UDP and doing a broadcast would be more efficient.
In any case, I believe you have to disconnect your socket from the current machine before you can connect it to the next machine.
If you need to keep multiple connections open, then you need multiple sockets on your client, one for each server, to maintain the connection to a given machine.
__________________
There Is An Island Of Opportunity In The Middle of Every Difficulty.
Miss That, Though, And You're Pretty Much Doomed.
Reply With Quote
Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Forum Jump

Advertisement:





Free Publications
The ASP.NET 2.0 Anthology
101 Essential Tips, Tricks & Hacks - Free 156 Page Preview. Learn the most practical features and best approaches for ASP.NET.
subscribe
Programmers Heaven C# School Book -Free 338 Page eBook
The Programmers Heaven C# School book covers the .NET framework and the C# language.
subscribe
Build Your Own ASP.NET 3.5 Web Site Using C# & VB, 3rd Edition - Free 219 Page Preview!
This comprehensive step-by-step guide will help get your database-driven ASP.NET web site up and running in no time..
subscribe
Socket Multiple Connection VB.NET
Socket Multiple Connection VB.NET
Socket Multiple Connection VB.NET Socket Multiple Connection VB.NET
Socket Multiple Connection VB.NET
Socket Multiple Connection VB.NET
Socket Multiple Connection VB.NET Socket Multiple Connection VB.NET Socket Multiple Connection VB.NET Socket Multiple Connection VB.NET Socket Multiple Connection VB.NET Socket Multiple Connection VB.NET Socket Multiple Connection VB.NET
Socket Multiple Connection VB.NET
Socket Multiple Connection VB.NET
 
Socket Multiple Connection VB.NET
Socket Multiple Connection VB.NET
 
-->