?

Log in

No account? Create an account
Protocol\Packet question, (for C, C++ on Linux) - LiveJournal Client Discussions [entries|archive|friends|userinfo]
LiveJournal Client Discussions

[ userinfo | livejournal userinfo ]
[ archive | journal archive ]

Protocol\Packet question, (for C, C++ on Linux) [Jul. 15th, 2002|08:00 am]
LiveJournal Client Discussions
lj_clients
[franknbeans]
[mood |tiredtired]
[music |Drowning Pool - Tear Away]

Hello all i'm trying to get this protocol thing down, but have a question i can't seem to asnwere. It deals with using different modes, and when using different ones is the returned packet structure the same across the board ? (minus some specific values valid to say, "login", or "getfriends"). I've been trying to use the "getfriends" mode with no luck. I've tried : sprintf(getfriends,"(all other info included, as well as size\length) mode=getfriends&name=%s&password=%s", ljName, ljPass); then just sending it to the already open connection. But /if/ i get a response it's not the one described in the "Modes" docs. I'm using C, but C++ code is just fine if you can help. Thanks in advance.. ....Frank M....
linkReply

Comments:
[User Picture]From: rdiamond
2002-07-15 08:51 pm (UTC)
I've got a client I started writing which may have some useful code, at http://sourceforge.net/projects/liveqt . It's for the Sharp Zaurus, but the Qt calls should be mappable to socket() stuff.
(Reply) (Thread)
[User Picture]From: sapphirecat
2002-07-16 11:12 am (UTC)

Check for HTTP stuff?

Are you doing CRLF for the newlines? Have your variables been URL-encoded?

If you don't get the documented response, what do you get? Do you get the same thing if you try the same request via telnet?
(Reply) (Thread)
[User Picture]From: sapphirecat
2002-07-16 11:14 am (UTC)

Re: Check for HTTP stuff?

Do any modes work?
(Reply) (Parent) (Thread)
[User Picture]From: xb95
2002-07-16 11:18 am (UTC)
You are using POST and not GET, right? And if you don't mind, paste *exactly* what your client is sending to the server (sans password) and we should be able to help... :)
(Reply) (Thread)
From: franknbeans
2002-07-16 01:29 pm (UTC)

Here's what i'm using....

Alright i get a perfect return when i use the login mode..
The code i'm using for the getfriends mode is :
sprintf(getfriends, "POST /interface/flat HTTP/1.0\r\nHost: www.livejournal.com\r\nContent-type: application/x-www-form-urlencoded\r\nContent-length: %d\r\n\r\nmode=getfriends&user=franknbeans&password=xxxxxxxxxx", 78, ljName, ljPass);
bytes_sent = send(sockd, getfriends, strlen(getfriends), 0);
/*error check*/
do {
bytes_read = recvfrom(sockd, buffer, sizeof(buffer) - 1, 0, &temp, sizeof(temp));
printf("Bytes_read -> %d\nBuffer-> %s", bytes_read, buffer);
}while(bytes_read != 0);

Now all it does is say 0 bytes read, and if anything is there for buffer it's garbled junk, or what i recieved from the login. If you need more of the code let me know i'll post it. I thought this was the relevant info though. Thanks again for all the help... Frank M.
(Reply) (Thread)
From: cyberlizard
2002-07-17 12:26 am (UTC)

Dude, I have a set of C modules / C++ classes you could use. So far, I've encoded the login and post modes, but you could extend them— there's an internal helper function/method that does most of the work, all the mode functions have to do is pass the important variables as a request structure. It's in the code. Email me at cyberlizard0 AT yahoo.com if you want to use 'em.

(Reply) (Thread)