I have two ws_putlines..i have that one, and then putline2
I have two ws_putlines..i have that one, and then putline2
the error is happening when it is trying to send the byte ordering to the server. i just emailed one of my co-workers she said since the server is in unix, the windows one either doesnt have it, or is different from the one on unix. i dont know how to convert the byte ordering the way its suppose to be.
this is what my co-worker said:
Interesting...
So there are two kinds of byte orders that I know of "little endian" and
"big endian". The difference is in how they order their bytes. For
example, 2 could be 00000010 or 01000000. The stp server tries to check
which order your using so that if it's not the same, it can swap the bytes
for you where necessary. Here's a code snippet from the server:
So either windows has neither of those byte orders, or perhaps you areCode:/* Receive the sample '2', to get the byte-order of the client */ two= 0; fread(&two,1,4,fdr); if(two == 2) byteswap= 0; /* same order */ else { if(two == 0x02000000 ) byteswap =1; /*reverse order */ else { if(two == 0x02000000 ) byteswap =1; /*reverse order */ else { puterror("unknown byte-order on client - cannot function - exit\n"); exit(-1); } }
neglecting to send the number 2 through to the server.
The unix client does this here:
Code:/* send a binary sample so the server can establish byte order */ two= 2; ws_putdata(&two,4); fflush(ws_fdw);
sorry, u were right, it worked, thanks a lot!
[edit]
Posted while you were posting.
[/edit]
Argh!
>> I have two ws_putlines..i have that one, and then putline2<<
There is no putline2 in the code you posted. Either way you are using ws_putline():
and it is wrong!Code:strcpy(line, "STP stpisgreat 1.4 stpc\n"); ws_putline(line);
>> So either windows has neither of those byte orders, or perhaps you are
neglecting to send the number 2 through to the server. <<
No what is happening, which I've been pointing out repeatedly, is that you send the authorization line twice because of your version of ws_putline(). This means, that when the server comes to read the two, it is getting instead the second copy of the authorization line.
If you replace your ws_putline and delete the declaration line it will make things a lot easier.
Yeah, i did that, you were right, i had two ws_putdata(), and i changed the code, and it worked. I have a question, I mean everything works, but why did I have to use raw socket functions instead of doing it the way unix did it?
i changed the code of the ws_putline that is, not the putdata
Are you sure it is working? In the code you posted you are still using fread() at about 455 and ws_getline2() at about 495. Both of these are likely to fail.
>> I mean everything works, but why did I have to use raw socket functions instead of doing it the way unix did it? <<
In unix a socket handle is a normal file descriptor which you can pass to fdopen(). In windows a socket is not a C file descriptor and you can not pass it to fdopen. You are meant to be able to pass the socket to _open_osfhandle() to get a C file descriptor but it doesn't seem to work.
yeah its working, u can try it if you want, i posted it up, everything is working great, im not using ws_getline2() anymore. i took it out
Thanks a lot, I owe you one...or maybe 10, or 100. I dont know, but thanks a lot, i didnt really know much about networking, they just had me doing this for my internship, so im learning as we speak. So thanks a lot, im going to try to read through the code to try to understand it better. Would it be a problem if i were to ask you a question about some of the stuff we went over some other time in a message or something?
Many people suggest Beej as a good guide to network programming. Unfortunately, some of it is unix specific but it is worth a read.
>> Would it be a problem if i were to ask you a question about some of the stuff we went over some other time in a message or something? <<
No problems.
Thanks a lot. :-)
>>unknown byte order format
Any reason you're not using ntohl() and htonl() etc?
Also, there's some good examples of read functions here:
http://cboard.cprogramming.com/showt...333#post321434
Adapt them to suit if you want.
When all else fails, read the instructions.
If you're posting code, use code tags: [code] /* insert code here */ [/code]
thanks hammer