Java Forums

Main Menu
Home
Today's Posts
FAQ
Search
Contact Us

Java Network
Linux Archive
Java Tips
Java Tips Blog

Sponsored Links





Welcome to the Java Forums.

You are currently viewing our boards as a guest which gives you limited access to view most discussions and access our other features. By joining our free community, you will:

  • have access to post topics
  • communicate privately with other members (PM)
  • not see advertisements between posts
  • have the possibility to earn one of our surprises if you are an active member
  • access many other special features that will be introduced later.

Registration is fast, simple and absolutely free so please, join our community today!

If you have any problems with the registration process or your account login, please contact us.

Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 08-24-2008, 03:09 PM
Member
 
Join Date: Aug 2008
Posts: 1
zeyneqp is on a distinguished road
to send float array with TCP socket
Hi,
I try to send a float array with TCP socket, but unfortunately, I can not do that. my server is c++, and my client is writen with java applet. they can send string each other but not send float, or array. please, can anybody help??
Bookmark Post in Technorati
Reply With Quote
Sponsored Links
  #2 (permalink)  
Old 08-24-2008, 03:57 PM
Norm's Avatar
Senior Member
 
Join Date: Jun 2008
Location: Heredia, Costa Rica
Posts: 2,223
Norm is on a distinguished road
Quote:
I can not do that.
Can you explain why?
If your communication is only String and has no binary capability, you will have to convert the floats to String and have an agreement/protocol with the server code so it knows what it is receiving and how to handle it.
Are you sure you can't sent binary?
If you send binary, the server will have to know how to reconstruct the data back into useful info.
Bookmark Post in Technorati
Reply With Quote
  #3 (permalink)  
Old 08-24-2008, 08:00 PM
fishtoprecords's Avatar
Senior Member
 
Join Date: Jun 2008
Posts: 475
fishtoprecords is on a distinguished road
Over TCP/IP, you sent bytes. Its the rule.

It is really a bad idea to send float or int, as you need to be sure that both sides interpret the bytes and bits the same. Google big endian and little endian for examples.

Corba and other complex systems are about marshalling and unmarshalling binary things so they are understood on both ends. Of course Corba is complex and arcane itself.

Advice: move string representations. Convert to and from binary as needed.
Bookmark Post in Technorati
Reply With Quote
  #4 (permalink)  
Old 08-29-2008, 02:47 PM
ProjectKaiser's Avatar
Member
 
Join Date: Aug 2008
Location: Saint-Petersburg, Russia
Posts: 47
ProjectKaiser is on a distinguished road
Novadays it is possible to use string-based JSON format. There are bunch of libraries for any programming language.

Ref www dot json dot org
Bookmark Post in Technorati
Reply With Quote
  #5 (permalink)  
Old 08-29-2008, 10:28 PM
fishtoprecords's Avatar
Senior Member
 
Join Date: Jun 2008
Posts: 475
fishtoprecords is on a distinguished road
Quote:
Originally Posted by ProjectKaiser View Post
Novadays it is possible to use string-based JSON format. There are bunch of libraries for any programming language.
OK, I'll buy that JSON is the new cool Corba, but I still don't understand any need to send binary over a network when you can just send text messages. Its a thousand times easier to debug.
Bookmark Post in Technorati
Reply With Quote
  #6 (permalink)  
Old 08-30-2008, 12:42 AM
ProjectKaiser's Avatar
Member
 
Join Date: Aug 2008
Location: Saint-Petersburg, Russia
Posts: 47
ProjectKaiser is on a distinguished road
Why binary ? JSON produces human-readable text stream. Advantage is that you do not need to write your own serialization/deserialization code - this is what JSON library does for some primitive types and objects.

Last edited by ProjectKaiser : 08-30-2008 at 12:52 AM.
Bookmark Post in Technorati
Reply With Quote
  #7 (permalink)  
Old 08-30-2008, 05:48 AM
fishtoprecords's Avatar
Senior Member
 
Join Date: Jun 2008
Posts: 475
fishtoprecords is on a distinguished road
Quote:
Originally Posted by ProjectKaiser View Post
Why binary ? JSON produces human-readable text stream.
All it is doing is seralizing it for you. If you are sending an int or float, you are sending binary. As you say, JSON can marshal it for you.

But I believe its a weak design to send binary when you can simply send text messages. You can send text with two or three lines of simple Java, no libraries, no API, nothing fancy. To me, this is much better.

YMMV
Bookmark Post in Technorati
Reply With Quote
Sponsored Links
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Send an array via Socket lene Networking 0 04-23-2008 06:29 PM
String to Float durahman New To Java 2 02-12-2008 02:17 AM
Float to String mew New To Java 4 12-29-2007 07:08 PM
Server socket - send image to client Hinty Networking 0 11-30-2007 10:15 PM
send files through socket bbq Advanced Java 1 06-05-2007 04:08 AM


All times are GMT +3. The time now is 01:34 AM.


VBulletin, Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO ©2007, Crawlability, Inc.
Copyright ©2006 - 2007, www.java-forums.org