Page 1 of 1

Unresponsive UDP AUTH command

Posted: Sat May 28, 2005 2:59 am
by MistaMuShu
Hi,

I thought the UDP api looked simple enough, so I started to poke around just so I can get a better understanding of it. It didn't take long for me to run into a snag though.

I thought I'd use Python for some practice:

Code: Select all

uid = "mistamushu"
password = "..."
apiversion = '2'
clientname = 'xyztesting'
clientversion = '1'
tag = 'oyasumi'
host, port = ("anidb.ath.cx", 9000)

authstr = "AUTH user=%s&pass=%s&protover=%s&client=%s&clientver=%s&tag=%s" % (uid, password, apiversion, clientname, clientversion, tag)
... [i]initialize a udp socket and connect[/i]
    print sock.send(authstr)
    time.sleep(1)

    print "receiving..."
    print sock.recv(500)
...
That's the gist of it, and I compared it with this earilier posting. I don't see what I could be doing wrong. Any help would be greatly appreciated. I've tried scrounging around the forums, but I think I must be missing something simple.[/i][/url]

Posted: Sat May 28, 2005 8:14 am
by epoximator
try: anidb.ath.cx -> api.anidb.info

Posted: Sat May 28, 2005 3:06 pm
by MistaMuShu
That didn't do it. I'm pretty new to network programming, so this might be a silly question:

My guess is that after I send my AUTH string over a socket, I should call recv and expect data from that same socket. Is this true for UDP and TCP in general?

Otherwise, should I send my AUTH string, and bind my client to a port and have it listen for a new connection from the anidb server? i.e. Act like a server?

One other detail I notice is that my program hangs on the recv call as if it's waiting indefinately for something to appear on that socket. I tried setting different delays between sending my AUTH string, and recv'ing, but no luck on that either.

Posted: Sat May 28, 2005 3:28 pm
by epoximator
MistaMuShu wrote:My guess is that after I send my AUTH string over a socket, I should call recv and expect data from that same socket. Is this true for UDP and TCP in general?
That is true.
MistaMuShu wrote:I tried setting different delays between sending my AUTH string, and recv'ing, but no luck on that either.
No need to wait, but smart to set a timeout.

You should try to PING first to check the connection. Anidb does probably not receive anything from you.

Posted: Sat May 28, 2005 4:41 pm
by MistaMuShu
Ping to anidb.ath.info seems fine, but to .cx is not. I took out the delay between sending AUTH and recv'ing, but still no luck.

Are there any examples of just basic AUTH or other commands? I have the UDP API spec, but a concrete example would be great. I don't really mind what language it's in.

And one more quickie, is there a way to check if a particular port is open with ping? I'm not really familiar with port-scanners, and I'm afraid to get banned if I use one incorrectly on anidb udp server.

Thanks for being so helpful epox ;-)

Posted: Sat May 28, 2005 5:01 pm
by epoximator
u can't ping a specific port. i meant the udp-api PING command. a spimple way to test the connection is to use the ping button in webaom. anyway.. check out ExElNeT's client http://www.anidb.net/forum/viewtopic.php?p=19138#19138. it is open source. (unpack the jar)

Posted: Sun May 29, 2005 9:36 am
by exp
here is a simple api usage example:

Code: Select all

> PING
< 300 PONG
> AUTH user=xxx&pass=xxx&protover=2&client=abcdtest&clientver=1
< 200 yfKyt LOGIN ACCEPTED
> FILE fid=1&s=yfKyt
< 220 FILE
1|1|1|1|0|169142272|a62c68d5961e4c601fcf73624b003e9e|Seikai no Monshou - 01 - Invasion - [AH].avi
> LOGOUT s=yfKyt
< 203 LOGGED OUT
>: send lines
<: received lines

BYe!
EXP