Friday 15 June 2012

Labview TCP connection with Java -



Labview TCP connection with Java -

i'm trying send info labview on tcp socket , receiving info java.

i'm using illustration tcp vi labview (i cant post pictures).

i realize there's tcp read, haven't gotten point yet. problem dealing types.

class="lang-java prettyprint-override">import java.io.*; import java.net.*; public class javaapplication3 { public static void main(string[] args) throws ioexception { string serverhostname = new string ("97.77.53.127"); socket echosocket = null; printwriter out = null; bufferedreader in = null; seek { echosocket = new socket(serverhostname, 6340); out = new printwriter(echosocket.getoutputstream(), true); in = new bufferedreader(new inputstreamreader( echosocket.getinputstream())); } grab (unknownhostexception e) { system.exit(1); } grab (ioexception e) { system.exit(1); } bufferedreader stdin = new bufferedreader( new inputstreamreader(system.in)); string userinput; system.out.print ("input: "); while ((userinput = stdin.readline()) != null) { out.println(userinput); system.out.println("echo: " + in.readline()); system.out.print ("input: "); } out.close(); in.close(); stdin.close(); echosocket.close(); } }

my first problem want deal with, whenever receive input labview vi, in java programme get:

class="lang-none prettyprint-override">input: d echo: ?��/�?�~gʕ ?�$���;p?��g��j�?��"�?�?��;���h?� input: input: d echo: ?��/�?�~gʕ ?�$���;p?��g��j�?��"�?�?��;���h?� input:

i'm assuming problem type casting, don't know plenty prepare it. help appreciated.

ok, seek like:

int temp = 0; while( (temp = in.read()) != -1){ system.out.print( (char)temp ); }

just set somewhere in code. casts int returned char value, print out letters.

let me know how goes.

java tcp labview

No comments:

Post a Comment