| | |
passing data around
![]() |
•
•
Join Date: Mar 2007
Posts: 11
Reputation:
Solved Threads: 0
hi all,
I have been struggling for a while with my client/server program.
I have to authenticate in order to log on correctly.
I have managed to get most things sorted, asking for username ( which is a long integer (12) ) and also and customer ID (also an int (4)), and they are stored into 2 arrays. I can then send them from the client to the server.
For now all I am doing is printing the two integers out to see that they are correct, however when if I printf the data the numbers do not match what I typed into the client, and I do not know why ?
It is pointless trying to go onto the next stage of validating the numbers from a text file until i get this part sorted.
Somebody said that i needed to convert my integers into strings in my client program before sending them to the server as they will get corrupted...how on earth do i do this ? Is this true ? Do i need to do it, or is there another way?
Cheers for looking and any advice would be greatly appreciated.
Fatboy
I have been struggling for a while with my client/server program.
I have to authenticate in order to log on correctly.
I have managed to get most things sorted, asking for username ( which is a long integer (12) ) and also and customer ID (also an int (4)), and they are stored into 2 arrays. I can then send them from the client to the server.
For now all I am doing is printing the two integers out to see that they are correct, however when if I printf the data the numbers do not match what I typed into the client, and I do not know why ?
It is pointless trying to go onto the next stage of validating the numbers from a text file until i get this part sorted.
Somebody said that i needed to convert my integers into strings in my client program before sending them to the server as they will get corrupted...how on earth do i do this ? Is this true ? Do i need to do it, or is there another way?
Cheers for looking and any advice would be greatly appreciated.
Fatboy
If the client is MS-Windows and the server is *nix then you have Big Endian-Little Endian proglem The easiest way I know to correct it is to transfer the data as ascii text then use atol() or similar function on server side to convert back to integer in its own format.
Don't PM me with questions -- you might get a nasty PM in response. If you have a question then post it in one of the forums.
>> i am running this on unix by the way
if both client and server are on the same os (unix) then the problem is something else.
>> how do i change the integer into an ascii cod
c++ example, use stringstream class
c example
if both client and server are on the same os (unix) then the problem is something else.
>> how do i change the integer into an ascii cod
c++ example, use stringstream class
c Syntax (Toggle Plain Text)
#include <sstream> ... ... stringstream stream; int n = 123; stream << n; cout << stream.str();
c example
c Syntax (Toggle Plain Text)
#include <stdio.h> #include <string.h> ... ... char buffer[80]; int n = 123; sprintf(buffer,"%d", n); printf("%s\n", buffer);
Last edited by Ancient Dragon; Mar 25th, 2007 at 4:26 pm.
Don't PM me with questions -- you might get a nasty PM in response. If you have a question then post it in one of the forums.
![]() |
Similar Threads
- Passing data from forms from one page to another (JavaScript / DHTML / AJAX)
- Please help with passing data from one form to another form (VB.NET)
- Passing data from datagridview to textboxes (VB.NET)
- passing the recordset data into an Array (ASP)
- Challenging Problem in PASSing Data to Server, Plz Help (ASP)
- need halp passing array data (C#)
- Solution for software system/data sharing/integration (Computer Science)
Other Threads in the C Forum
- Previous Thread: fork() and wait()
- Next Thread: print the fields of a structure
| Thread Tools | Search this Thread |
* adobe ansi api array asterisks binarysearch calculate centimeter char character cm convert copyanyfile copyimagefile copypdffile cprogramme creafecopyofanytypeoffileinc createcopyoffile createprocess() csyntax directory feet fflush fgets file floatingpointvalidation fork forloop frequency givemetehcodez global gtkgcurlcompiling hacking highest homework i/o inches infiniteloop interest intmain() kernel kilometer km linked linkedlist linux linuxsegmentationfault list locate match meter microsoft mqqueue mysql number oddnumber odf open opendocumentformat openwebfoundation owf pattern pdf performance posix power probleminc program programming pyramidusingturboccodes radix read recv recvblocked repetition research scanf scheduling segmentationfault send sequential single socketprograming socketprogramming stack standard string suggestions systemcall turboc unix urboc user variable voidmain() wab whythiscodecausesegmentationfault win32api windows.h






