Click here to Skip to main content
15,888,579 members
Please Sign up or sign in to vote.
1.00/5 (3 votes)
See more:
When this part runs in my program, I get the error "Input string was not in a correct format" when the Client.Connect line runs, could somebody help me, Thanks.

Public Client As Socket
    Public IP As String = "69.172.201.153"
    Public Port As Integer = 80
 Client = New Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp)
        Client.Connect(New IPEndPoint(Long.Parse([IP]), [Port]))


What I have tried:

I haven't found anything to do yet.
Posted
Updated 19-Jun-17 2:26am
v2
Comments
Kornfeld Eliyahu Peter 18-Jun-17 6:31am    
RTFM
bob marley123 18-Jun-17 6:42am    
How should I improve my question?
Kornfeld Eliyahu Peter 18-Jun-17 7:08am    
You need not - all you have to do is to read the documentation (all 4) for Socket.Connect...
Dave Kreskowiak 18-Jun-17 10:14am    
What's with the square brackets? You don't need them for anything in the code.

You also don't need to "Long.Parse" the IP address string and don't even need to create an IPEndPoint object. Just pass the IP address string in as the first parameter.

1 solution

Here is an example: Synchronous Client Socket Example | Microsoft Docs[^]
VB
Dim remoteEP As New IPEndPoint(ipAddress, 11000)  
Dim sender As New Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp)  
sender.Connect(remoteEP)
 
Share this answer
 

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


CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900