LinuxQuestions.org
Review your favorite Linux distribution.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 02-22-2005, 05:35 PM   #1
maldini1010
Member
 
Registered: Sep 2004
Location: Montreal
Posts: 53

Rep: Reputation: 15
C++ Socket: How to read a long


Hi,


I am able to read a long in Java with readlong();

does anyone know how to read a long in c++

Thanks guys
maldini

Last edited by maldini1010; 02-22-2005 at 05:36 PM.
 
Old 02-23-2005, 05:45 AM   #2
Mara
Moderator
 
Registered: Feb 2002
Location: Grenoble
Distribution: Debian
Posts: 9,696

Rep: Reputation: 232Reputation: 232Reputation: 232
Well...read(fd, buffer, sizeof(long)) maybe? What do you want to read exactly and from where?
 
Old 02-24-2005, 11:13 PM   #3
maldini1010
Member
 
Registered: Sep 2004
Location: Montreal
Posts: 53

Original Poster
Rep: Reputation: 15
Hi,

I am trying to interface a Server implemented in Java with a my Client which i am writing in C++.
The server is sending information with the function call writelong(byte[]). I think the what you have recommended works. thanks alot.

maldini
 
Old 02-25-2005, 03:56 PM   #4
Mara
Moderator
 
Registered: Feb 2002
Location: Grenoble
Distribution: Debian
Posts: 9,696

Rep: Reputation: 232Reputation: 232Reputation: 232
Remember that with C/C++ you must remember about big/little endian. htons(), htonl(), ntohl() and ntohs() functons do the possible conversions.
 
  


Reply



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

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
cannot read data at server socket, though client socket sends it jacques83 Linux - Networking 0 11-15-2005 01:58 PM
unix domain socket: how to know if i use recvmsg or read Thinking Programming 3 09-23-2005 01:51 AM
poor java socket read performance bobwall Linux - Networking 0 01-21-2005 09:55 PM
In Serious need of help (long read) kith Linux - General 6 03-27-2004 10:16 AM
read socket adoyee Programming 3 02-26-2004 06:06 AM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 07:01 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration