[2873] in java-interest

home help back first fref pref prev next nref lref last post

Re: C structures and Java

daemon@ATHENA.MIT.EDU (Suresh K Jois)
Wed Oct 18 22:45:18 1995

Date: Wed, 18 Oct 1995 17:37:23 -0700
To: mikea@ai.mit.edu (Michael Afergan)
From: suresh@shop.internet.net (Suresh K Jois)
Cc: java-interest@java.sun.com

>  How should I read the information?  Will it simply be a string
>followed by an int, followed by...whatever the C server sends?  If so,
>how easily will this translate in to Java data types?

It would be like reading from stdin, except the Java applet would be reading
from a socket. The java socket or NetworkClient class returns whatever it
reads as a byte (or char ?) array, which you would need to tokenize and
parse out into the appropriate number of chars and ints. This is easy to do
using a class like DataInputStream. Of course you would need to know the
exact sequence, number and format of chars and ints the server sends out.

- suresh

>
>  -- Mike
>
>----------------------
>   >  I am receiving information as a socket client.  If the server is
>   >written in C, is there any easy way for me to interpret the data if it
>   >is sent as a structure?  If so, are there any limitations of the
>   >fields within it (I assume that pointers are outlawed.)?  Has anyone
>   >tried something like this before, or is it better to change the C
>   >server to send characters?  (I'm assuming that if the C server sends a
>   >character, my applet will have no trouble translating it into the same
>   >character.)
>
>   I've done this before. I assume your client is a Java program or applet, and
>   the server communicates over a socket. If yes, it is best to send characters
>   (sprintf to a char array and write() it down the socket).
>
>   - Suresh
-----------------------------------------------------------------
Suresh K Jois. CyberSpace Gypsy. Virtual Spaces Architect.
Email: suresh@internet.net (Work)  sujo@netcom.com (Home)
WWW:http://www.internet.net
Traceroute: ->Informix->SiliconGraphics->Sun Microsystems
            ->Home Shopping Channel Inc/Internet Shopping Network
-----------------------------------------------------------------

-
Note to Sun employees: this is an EXTERNAL mailing list!
Info: send 'help' to java-interest-request@java.sun.com

home help back first fref pref prev next nref lref last post