Hi guys,
just want to ask how can I convert an IP address that is declared as String to type IPAddress? The reason why I come up with String IP address is because it came from a file. the connect method of socket class need IPaddress or host.
Hope you can help me...
17 2504
IPAddress ipAddr = IPAddress.Parse(strHostName);
Hi romcab
I changed your Topic title to make it more meaningful and appropriate to your query
Please remember to provide a meaningful Title for any threads started ( Please Use Appropriate Titles for New Threads!). This helps to ensure that other members, and also the general public, will have a better chance of finding answers to any similar questions.
- Shashi
Hi..
I dont have the hostname, I only have an Ip address but it's on type String since I get it on a textfile. My question is how can I translate the IpAdd of type String to type IPAdress..
Thanks
IPAddress ipAddr = IPAddress.Parse(strHostName);
IPAddress.Parse Method Converts an IP address string to an IPAddress instance.
A string that contains an IP address in dotted-quad notation for IPv4 and in colon-hexadecimal notation for IPv6.
IPAddress.Parse Method Converts an IP address string to an IPAddress instance.
A string that contains an IP address in dotted-quad notation for IPv4 and in colon-hexadecimal notation for IPv6.
my mistake...Your right. I follow your advice but I think I still have an error...Below is my code, I passed Ip "192.168.20.125" which is my pc ip address but after I looked at myIpAdd value i didnt see the 192.168.20.125. Is there anything wrong? - Private Sub SendData(ByVal IpAdd As String, ByVal sData As String)
-
-
Dim myIpAdd As IPAddress
-
-
'create a socket
-
Dim isocket As Socket
-
isocket = New Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp)
-
-
myIpAdd = IPAddress.Parse(IpAdd)
-
-
'resolve IPAddress
-
'myIpAdd = Dns.GetHostAddresses(IpAdd)
-
-
'connect to remote host
-
Try
-
isocket.Connect(myIpAdd, 80)
-
-
Catch se As SocketException
-
MsgBox("Socket Exception: {0}", se.SocketErrorCode)
-
-
Catch ex As Exception
-
MsgBox("UnExpected exception : {0}", ex.ToString)
-
-
End Try
-
-
End Sub
Hi,
is there any exception that is being thrown?
If you want to check use the myIpAdd.ToString() to check if the IPAddress is correct.
It should show the same (worked for me)
Hi,
is there any exception that is being thrown?
If you want to check use the myIpAdd.ToString() to check if the IPAddress is correct.
It should show the same (worked for me)
Hi there,
Yes it is the same. The Address member is obsolete based on msdn. Anyway, is there a way how can I typecast String type to a Byte() ? Sorry, this is my first time to use VB that's why i'm having this weird/stupid questions.
Thanks
if you use the Parse method then it creates the class for you with the required ip address.
Its only the Address Property which is obsolete.
Your IPAddress class object is fine otherwise
is there an exception due to which you are worried with this object?
http://www.chilkatsoft.com/faq/DotNetStrToBytes.html
if you use the Parse method then it creates the class for you with the required ip address.
Its only the Address Property which is obsolete.
Your IPAddress class object is fine otherwise
is there an exception due to which you are worried with this object?
I'm receiving Socket exception when I changed the port number.
http://www.chilkatsoft.com/faq/DotNetStrToBytes.html
Thanks...I have one last question.. I'm having hard time to add double quote to a string.
example:
stemp1 = "<" + stemp + ">" = <stemp>
but how about for double quote?
output should be: "stemp"?
I found one answer but it only applies when value of string is constant.
example
stemp = ""Hello"" = "Hello"
the \ is used as an escape character
string s = "\"hello\"";
that will give the output "hello" and not hello
the \ is used as an escape character
string s = "\"hello\"";
that will give the output "hello" and not hello
Hi tnx for all your help. I was able to send the data but byte per byte. I would like to try sending the whole string but there is not connect overload that can accept string as Input. There is another overload method which uses IList but I cannot understand. Can you help me guys how to use it?
Tnx again...
the \ is used as an escape character
string s = "\"hello\"";
that will give the output "hello" and not hello
Hi...
It's not working when hello is a variable...It only works for constant...
All you are doing is talking to your webserver on port 80? Try the HttpWebRequest object?
To answer you string question: -
dim dan as string
-
dim danwithquotes as string
-
-
dan = "hello";
-
danwithquotes = "\"" + dan + "\"";
-
'now dan will = hello
-
'and danwithquotes will = "hello"
-
All you are doing is talking to your webserver on port 80? Try the HttpWebRequest object?
To answer you string question: -
dim dan as string
-
dim danwithquotes as string
-
-
dan = "hello";
-
danwithquotes = "\"" + dan + "\"";
-
'now dan will = hello
-
'and danwithquotes will = "hello"
-
Hi...
The String don't works for me:
'test ""
Dim stemp As String = "Hello"
stemp = "\"" + stemp + " \ ""
I'm using another port with my code, i just forgot to change my port number in my previous port.
Hi...
The String don't works for me:
'test ""
Dim stemp As String = "Hello"
stemp = "\"" + stemp + " \ ""
I'm using another port with my code, i just forgot to change my port number in my previous port.
That is my fault, forgot VB uses & and not + -
stemp = "\"" & stemp & " \ ""
-
Sign in to post your reply or Sign up for a free account.
Similar topics
by: Martoni |
last post by:
I need to parse a string with an embedded email address.
The string always has the format NAME (name@domain) SOMETEXT.
What I need to get is the email address as name@domain.
I came up with this...
|
by: Steve |
last post by:
Is there equivalent of sscanf function in .NET?
I need to parse string with network MAC address (For example like
11-22-33-44-55-66) and extract each segment into array of bytes.
Can anyone...
|
by: sophocles the wise |
last post by:
I am researching this topic without a satisfactory solution so far.
Please let me know which is the easiest way to receive email using VB
code. All I need is to test source address or subject line...
|
by: Stressed Out Developer |
last post by:
We have an application that has a 200 count loop that does the following:
' Each time thru the loop we pass the next IP Address is a range (aka
192.168.4.50 thru 192.168.4.254)
Try
If...
|
by: Mukesh |
last post by:
Hi i want to use AJAX.net in my Existing Application
I have already installed the ajax .net
..net 3.0
and using VS 2005
in the old application i have added a new web form then script manager...
|
by: shamirza |
last post by:
· When was .NET announced?
Bill Gates delivered a keynote at Forum 2000, held June 22, 2000,
outlining the .NET 'vision'. The July 2000 PDC had a number of sessions
on .NET technology, and...
|
by: Mukesh |
last post by:
HI
all
I have created a user ctrl for user info.
On which i have used some asp ctrls, .net Ajax (Atlas) Ctrls and
validation as described below
Name TxtBox1(RequiedFieldValidator,...
|
by: AdrianH |
last post by:
Assumptions
I am assuming that you know or are capable of looking up the functions I am to describe here and have some remedial understanding of C++ programming.
FYI
Although I have called...
|
by: Steve |
last post by:
Hello-
Your assistance with this issue is greatly appreciated.
Environment:
- Load-balanced IIS 6.0 servers (Win2003)
- web servers point (via UNC path) to a Microsoft File Cluster on...
|
by: Jan Vinten |
last post by:
Hi all,
I got into some trouble trying to bind to a specific IP address.
Code:
Private mobjClient As TcpClient
mobjClient = New TcpClient(IPAddress.Parse("10.16.104.87").ToString,
8892)
|
by: Charles Arthur |
last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
|
by: ryjfgjl |
last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
|
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...
|
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...
|
by: Hystou |
last post by:
There are some requirements for setting up RAID:
1. The motherboard and BIOS support RAID configuration.
2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
|
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,...
|
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: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
| |