Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: VB8.0 TCP/IP
You probably want to ask why.
Because in order to talk to a certain hardware device,
It will only respond to my requests if the source computer uses port 7777.
 
I'm using VB2005, ya, it's old.
 
Here is a smattering of my code.
Dim tcpClient As New System.Net.Sockets.TcpClient()
       tcpClient.Connect("192.168.1.4", 2000)
       Dim networkStream As NetworkStream = tcpClient.GetStream()
       If networkStream.CanWrite And networkStream.CanRead Then
           ' Send some data.
           Dim sendBytes As [Byte]() = Encoding.ASCII.GetBytes("IE") & Chr(13)
           networkStream.Write(sendBytes, 0, sendBytes.Length)

Would i somehow use the following?
 Dim localEP As System.Net.EndPoint = "192.168.1.10:7777"      
 tcpClient.Client.Bind(localEP)
Posted 2-Dec-11 10:34am
jestal468
Edited 2-Dec-11 10:36am
v2
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 1

Just connect to the remote system like this :
 
tcpClient.Connect("192.168.1.10", 7777)
  Permalink  
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 2

Thanks,
It seems i tried that and had some problem with it.
Yesterday i found this code that worked.
                  Dim localIP As IPAddress = IPAddress.Parse("192.168.1.17")
                  Dim localPort As Int16 = 7775
                  Dim remoteIP As IPAddress = IPAddress.Parse("192.168.1.46")
                  Dim remotePort As Int16 = 7777
                  Dim remoteEP As IPEndPoint = New IPEndPoint(remoteIP, remotePort)
                  Dim localEP As IPEndPoint = New IPEndPoint(localIP, localPort)
                  Dim client As TcpClient = New TcpClient(localEP)
                  client.Connect(remoteEP)
  Permalink  

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
0 OriginalGriff 505
1 Maciej Los 325
2 Richard MacCutchan 265
3 Mathew Soji 220
4 BillWoodruff 210
0 OriginalGriff 8,804
1 Sergey Alexandrovich Kryukov 7,457
2 DamithSL 5,689
3 Maciej Los 5,279
4 Manas Bhardwaj 4,986


Advertise | Privacy | Mobile
Web04 | 2.8.1411028.1 | Last Updated 4 Dec 2011
Copyright © CodeProject, 1999-2014
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100