473,406 Members | 2,217 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,406 software developers and data experts.

Problem with IP address converstion from a string

I'm getting a connection error when I used the following code to connect to a
server on our LAN with IP address. Can someone take a look and tell me if
you see something wrong? I'm just getting back error message that it's time
out and no connection was made.
Thanks, Alpha

string ServerIP = "192.168.7.1"
m_socClient = new Socket(AddressFamily.InterNetwork, SocketType.Stream,
ProtocolType.Tcp);
String ServerIP = server;
String szPort = "22333";
int alPort = System.Convert.ToInt16 (szPort,10);

System.Net.IPAddress remoteIPAddress = System.Net.IPAddress.Parse(ServerIP);
System.Net.IPEndPoint remoteEndPoint = new
System.Net.IPEndPoint(remoteIPAddress, alPort);
m_socClient.Connect(remoteEndPoint);
Dec 27 '05 #1
1 1984
Alpha,

From what I can tell, this isn't an issue with parsing the IP address
from a string. You seem to have the port and the ip address converted
correctly.

Are you sure that the port 22333 on IP address 192.168.7.1 is valid?
Can you telnet into it?
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com

"Alpha" <Al***@discussions.microsoft.com> wrote in message
news:60**********************************@microsof t.com...
I'm getting a connection error when I used the following code to connect
to a
server on our LAN with IP address. Can someone take a look and tell me if
you see something wrong? I'm just getting back error message that it's
time
out and no connection was made.
Thanks, Alpha

string ServerIP = "192.168.7.1"
m_socClient = new Socket(AddressFamily.InterNetwork, SocketType.Stream,
ProtocolType.Tcp);
String ServerIP = server;
String szPort = "22333";
int alPort = System.Convert.ToInt16 (szPort,10);

System.Net.IPAddress remoteIPAddress =
System.Net.IPAddress.Parse(ServerIP);
System.Net.IPEndPoint remoteEndPoint = new
System.Net.IPEndPoint(remoteIPAddress, alPort);
m_socClient.Connect(remoteEndPoint);

Dec 27 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
by: Angelos Karantzalis | last post by:
Hi guys. I've come across a problem when I tried to serialize a class into xml, only to discover that the parent class's XML Serialization properties weren't included in the output xml. ...
3
by: Mark | last post by:
Hi all, i'm trying to serialize a class. Using the constructor of XmlSerializer i get these (odd?) errors: "File or assembly name goseij9w.dll, or one of its dependencies, was not found"....
0
by: Pallav | last post by:
i'm trying to build a lookup sine table to run some code in an embedded processor without floating point unit. the table is 256 values for 360 degrees. my code is below. the fixed point base is...
4
by: Stephen | last post by:
I have the following code working in order to create an array list and populate a datagrid however everytime i click my button the first item in the array and the first row in the datagrid are...
2
by: Christopher Weaver | last post by:
How does one convert a string to an int.
5
by: Jason Huang | last post by:
Hi, The SqlParameter myPM =new SqlParameter("@Address", txtAddress.Text) is working for update, but SqlParameter myPM =new SqlParameter ("@Address",SqlDbType.NVarChar,90,txtAddress.Text) is...
11
by: Daylor | last post by:
hi. im using option strict on. im doing in ,from the simple reason ,to be warn when there are implict conversion like string to int ,int to string. BUT. the price ,(now i see ), is very bad....
4
by: MRD | last post by:
Hi All, I found a useful bit of code on msdn in VC but need it in VB. I've started the conversion but can't quite finish. The code puts a custom Icon on a toolbar (In my case the Word Add-in...
8
by: chromis | last post by:
Hi, I'm writing a contacts section for a cms on a website, I've decided to write the section in OO code. So far I have my Contacts object and a page structure I would use for a procedural site. ...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.