Click here to Skip to main content
12,398,557 members (57,453 online)
Rate this:
Please Sign up or sign in to vote.
See more: VB8.0 VB 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("", 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 = ""
Posted 2-Dec-11 9:34am
Updated 2-Dec-11 9:36am
Rate this: bad
Please Sign up or sign in to vote.

Solution 1

Just connect to the remote system like this :

tcpClient.Connect("", 7777)
Rate this: bad
Please Sign up or sign in to vote.

Solution 2

It seems i tried that and had some problem with it.
Yesterday i found this code that worked.
                  Dim localIP As IPAddress = IPAddress.Parse("")
                  Dim localPort As Int16 = 7775
                  Dim remoteIP As IPAddress = IPAddress.Parse("")
                  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)

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

  Print Answers RSS
Top Experts
Last 24hrsThis month

Advertise | Privacy | Mobile
Web02 | 2.8.160721.1 | Last Updated 4 Dec 2011
Copyright © CodeProject, 1999-2016
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