I've created a client and server application.
The client - server are working able successfully passing messages to/from one another, when both are run on the same PC.
The Server will be run in my house, on a computer which is on a network of 2 PCs (MainPC and BedroomPC).
lets say for example,
that the ip address of my server = 1.2.3.4
the machine name of my server = MainPC
the port number of my server = 8888
When the client and server are running on the same PC, the following code works nicely:
clientSocket = New TcpClient()
clientSocket.Connect("MainPC", 8888)
Dim serverStream As NetworkStream
serverStream = clientSocket.GetStream()
Dim messageToSend As String = "blah"
Dim outStream As Byte() = System.Text.Encoding.ASCII.GetBytes(messageToSend)
serverStream.Write(outStream, 0, outStream.Length)
serverStream.Flush()
Now, I am going to run the client on a different PC, over the internet.
So, I want to connect the client, to the server which is already running. The server details are:
that the ip address of my server = 1.2.3.4
the machine name of my server = MainPC
the port number of my server = 8888
How would I connect the client to the above server, bearing in mind that I have to enter the ip address, machine name and port in the following code:
clientSocket = New TcpClient()
clientSocket.Connect("MainPC", 8888)
How can I insert the ip address of MainPC, into the statements above, bearing in mind that the server is running on only 1 computer ("MainPC") on my network ?
Thanks.
The client - server are working able successfully passing messages to/from one another, when both are run on the same PC.
The Server will be run in my house, on a computer which is on a network of 2 PCs (MainPC and BedroomPC).
lets say for example,
that the ip address of my server = 1.2.3.4
the machine name of my server = MainPC
the port number of my server = 8888
When the client and server are running on the same PC, the following code works nicely:
clientSocket = New TcpClient()
clientSocket.Connect("MainPC", 8888)
Dim serverStream As NetworkStream
serverStream = clientSocket.GetStream()
Dim messageToSend As String = "blah"
Dim outStream As Byte() = System.Text.Encoding.ASCII.GetBytes(messageToSend)
serverStream.Write(outStream, 0, outStream.Length)
serverStream.Flush()
Now, I am going to run the client on a different PC, over the internet.
So, I want to connect the client, to the server which is already running. The server details are:
that the ip address of my server = 1.2.3.4
the machine name of my server = MainPC
the port number of my server = 8888
How would I connect the client to the above server, bearing in mind that I have to enter the ip address, machine name and port in the following code:
clientSocket = New TcpClient()
clientSocket.Connect("MainPC", 8888)
How can I insert the ip address of MainPC, into the statements above, bearing in mind that the server is running on only 1 computer ("MainPC") on my network ?
Thanks.