Click here to Skip to main content
11,496,146 members (613 online)
The site is currently in read-only mode for maintenance. Posting of new items will be available again shortly.
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
Just connect to the remote system like this :

tcpClient.Connect("192.168.1.10", 7777)
  Permalink  
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 Sergey Alexandrovich Kryukov 10,401
1 OriginalGriff 8,910
2 Sascha Lefèvre 3,899
3 Maciej Los 3,422
4 Richard Deeming 2,600


Advertise | Privacy | Mobile
Web03 | 2.8.150520.1 | Last Updated 4 Dec 2011
Copyright © CodeProject, 1999-2015
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