Click here to Skip to main content
11,805,035 members (66,502 online)
Rate this: bad
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
Edited 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
0 OriginalGriff 305
1 Sergey Alexandrovich Kryukov 268
2 CPallini 210
3 Richard Deeming 190
4 CHill60 150
0 OriginalGriff 3,255
1 Maciej Los 1,990
2 KrunalRohit 1,907
3 CPallini 1,855
4 Richard MacCutchan 1,227

Advertise | Privacy | Mobile
Web01 | 2.8.151002.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