Hello
I have been trying for so long to send a message from one computer to another.
I know the ip address of both, and i'm able to send an image from one to another with serialization.
The problem is that both computers need to send data to each other, like this:
com1) Hello, can you send me your image please?
com2) Yes, here you go
com2) image-->com1
I think the problem is that the tcpclient is busy taking in the message so it forgets to send the return message.
Please don't link sites to me, as i have literally read through every molecule on the internet to no avail. [code only please, must be vb.net]
I got this from MSDN, but what I don't understand is how you can be sure there will be a response from the client before the sub ends, so I didn't use it.
Shared Sub Connect(ByVal server As [String], ByVal message As [String])
Try
Dim port As Int32 = 13000
Dim client As New TcpClient(server, port)
Dim data As [Byte]() = System.Text.Encoding.ASCII.GetBytes(message)
Dim stream As NetworkStream = client.GetStream()
stream.Write(data, 0, data.Length)
Console.WriteLine("Sent: {0}", message)
data = New [Byte](256) {}
Dim responseData As [String] = [String].Empty
Dim bytes As Int32 = stream.Read(data, 0, data.Length)
responseData = System.Text.Encoding.ASCII.GetString(data, 0, bytes)
Console.WriteLine("Received: {0}", responseData)
stream.Close()
client.Close()
Catch ex As Exception
MsgBox("Error")
End Try
End Sub
My code to send an image is from here:
http://lagabuse.com/forum/index.php?topic=90829.0</a>[
^], which was useful because the sender and receiver code are separate.
Please help me!