473,505 Members | 15,976 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Translating to VB.net

98 New Member
How do you translate this to VB.net? I don't know what to do with 'SocketAdress'

Thanks

Expand|Select|Wrap|Line Numbers
  1.    public static void main(String args[]) 
  2.     {
  3.  
  4.         try {
  5.             ipAddress = InetAddress.getByName(ipAdressString);
  6.         } catch (UnknownHostException e) {System.out.println("error: cannot find valid ip address");
  7.         }
  8.  
  9.     Port = 12203;
  10.         socketAddress = new InetSocketAddress(ipAddress, mohserverPort);
  11.  
  12.         startCommunication();
  13.     }
May 19 '08 #1
15 2180
Curtis Rutland
3,256 Recognized Expert Specialist
How do you translate this to VB.net? I don't know what to do with 'SocketAdress'

Thanks

Expand|Select|Wrap|Line Numbers
  1.    public static void main(String args[]) 
  2.     {
  3.  
  4.         try {
  5.             ipAddress = InetAddress.getByName(ipAdressString);
  6.         } catch (UnknownHostException e) {System.out.println("error: cannot find valid ip address");
  7.         }
  8.  
  9.     Port = 12203;
  10.         socketAddress = new InetSocketAddress(ipAddress, mohserverPort);
  11.  
  12.         startCommunication();
  13.     }
It looks like socketAddress is declared elswhere in the program. If you are using Visual Studio, right click it and click "Go To Definition." That'll take you to where it is declared.
May 19 '08 #2
Gangreen
98 New Member
That's simply a SocketAdress...The code is java. I'd like to know how to make thesame thing in vb.net

Expand|Select|Wrap|Line Numbers
  1.  
  2. static private SocketAddress socketAddress;
  3.  
  4. public static void main(String args[]) 
  5.     {
  6.  
  7.         try {
  8.             ipAddress = InetAddress.getByName(ipAdressString);
  9.         } catch (UnknownHostException e) {System.out.println("error: cannot find valid ip address");
  10.         }
  11.  
  12.     Port = 12203;
  13.         socketAddress = new InetSocketAddress(ipAddress, mohserverPort);
  14.  
  15.         startCommunication();
  16.     }
May 19 '08 #3
Plater
7,872 Recognized Expert Expert
Try the System.Net.Dns, System.Net.IPAddress or System.Net.IPEndPoint classes.

Although I wouldn't base anything off that code, it looks to be rather poorly constructed. If the ipaddress triggers that exception, it continues to try and use it regardless.
May 19 '08 #4
Curtis Rutland
3,256 Recognized Expert Specialist
That's simply a SocketAdress...The code is java. I'd like to know how to make thesame thing in vb.net
Sorry for the misunderstanding. I thought you were trying to port existing code that you were unfamiliar with. Sorry I couldn't help.
May 19 '08 #5
Gangreen
98 New Member
That IpEndPoint seems to do the trick.

how about java's DatagramPacket ? Is there a VB.net equivalent?
May 20 '08 #6
Plater
7,872 Recognized Expert Expert
Just create and use a socket set for UDP
May 20 '08 #7
Gangreen
98 New Member
Just create and use a socket set for UDP
Yes, ok, but the datagrampacket....is there a equivalent in vb.net? cause usage of that datagrampacket seems to be quite essential in the java program
May 20 '08 #8
Plater
7,872 Recognized Expert Expert
Everything is sent as bytes, just convert the datagrampacket to a byte[] and you'll have no problem

Look at the UdpClient class.
May 20 '08 #9
Gangreen
98 New Member
I'll do that, thanx for the info
May 20 '08 #10
Gangreen
98 New Member
Maybe this is a stupid question, but I have never worked with bytes before.

how do you write this in Vb.net?

Java:
Byte oob = (Byte)0xff
May 20 '08 #11
Plater
7,872 Recognized Expert Expert
Well that would work in C#, in vb.net the syntax is different.
(Going from java to c# woulda been easier as the syntax is very similar)
I think it's like
Expand|Select|Wrap|Line Numbers
  1. Dim oob as byte=0xff
  2.  
May 20 '08 #12
BigDaddyLH
1,216 Recognized Expert Top Contributor
Well that would work in C#, in vb.net the syntax is different.
(Going from java to c# woulda been easier as the syntax is very similar)
I think it's like
Expand|Select|Wrap|Line Numbers
  1. Dim oob as byte=0xff
  2.  
Expand|Select|Wrap|Line Numbers
  1. Dim oob As Byte = &HFF
May 20 '08 #13
Gangreen
98 New Member
could you explain the conversion from 0xff to &HFF for me please?
May 20 '08 #14
Gangreen
98 New Member
could you explain the conversion from 0xff to &HFF for me please?
Didn't the & stand for adress of, or is &H just the leading code for a byte?
May 21 '08 #15
Plater
7,872 Recognized Expert Expert
&H in VB must be the same as 0x in all the other languages.
May 21 '08 #16

Sign in to post your reply or Sign up for a free account.

Similar topics

6
1545
by: Davis Marques | last post by:
hi; I'm translating some PHP scripts to Python and have hit a roadblock with a for statement. If someone could explain to me how one should translate the multiple increment, evaluations, etc....
2
1437
by: Henrik S. Hansen | last post by:
How do you best go about translating characters like '\\n' to '\n'? This is for a configuration file parser, where the "backslash convention" is supported. The naive approach --...
1
2031
by: Michael Friendly | last post by:
I have a LaTeX document describing a long list of items that I want to translate to XML to treat these as a database. I've written a perl script to do the basic translation, and a basic DTD file,...
12
1629
by: Charles Law | last post by:
Hi guys A bit of curve ball here ... I have a document (Word) that contains a series of instructions in sections and subsections (and sub-subsections). There are 350 pages of them. I need to...
23
3118
by: gregf | last post by:
I have a paragraph of text pasted into a word document, it's in Polish, complete with polish characters. They show up just fine in word, but the program I use for web page programming, HomeSite,...
0
1107
by: Dylan Phillips | last post by:
I'm interested in how other participants in this new group are implementing SQL Full-Text Search on their Web Sites. How are you translating the user search string: "DirectX managed code" into...
1
1078
by: J | last post by:
Hi all, I just finished a asp.net project, which is based on English language, and all of sudden, client need different language also, say German, Chinese, etc. So, what is the best way, or I...
6
2523
by: Jumping Matt Flash | last post by:
The code i'm writing is using VB .NET and is for a web service returning a dataset, which is in turn to be used by an ASP .NET application displaying a datagrid. I'm currently populating a...
2
1618
by: kimi | last post by:
Voip Learning and Translating Tutorial Voice Over IP is a new communication means that let you telephone with Internet at almost null cost. How this is possible, what systems are used, what is the...
1
1853
by: timn | last post by:
Translating Access SQL queries into SQL subqueries. -------------------------------------------------------------------------------- I have a query in Access that uses a subquery, I would like...
0
7103
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...
1
7021
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...
0
7478
tracyyun
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...
0
5614
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
1
5035
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
4701
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
3188
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
3177
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
409
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

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.