TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
muhamad
NA
3
0
Socket Multiple Connection VB.NET
Sep 23 2013 7:05 PM
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 :
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 :
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
Answers (
0
)
ToString() and Name instance
c# .net - input output library function