• Welcome to Valhalla Legends Archive.
 

I'm on BNLS, now I've got Bnet issues....

Started by MyndFyre, September 25, 2003, 11:25 AM

Previous topic - Next topic

MyndFyre

Guys, you have no idea how happy I am to finally get online with BNLS.  It's been a long time coming.  Thanks for all your help!

It turned out that static thing that you guys suggested before was right.  I ended up using an asyncrhonous Socket.ReceiveFrom() method pointing to the BNLS server and port.  Worked fine, and I'm communicating great with BNLS.

Here's what I'm doing:

         this.epBNLS = new IPEndPoint(Dns.Resolve("bnls.valhallalegends.com").AddressList[0], 9367);
         this.epBnet = new IPEndPoint(Dns.Resolve("useast.battle.net").AddressList[0], 6112);
         this.bnlsOut = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp);
         this.bnet = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp);
         this.bnet.Connect(this.epBnet);
         this.bnlsOut.Connect(this.epBNLS);


         this.bnlsOut.BeginReceiveFrom(this.bnlsBuf, 0, 256, SocketFlags.None, ref this.epBNLS,
            new AsyncCallback(this.Bnls_Receive), this.bnlsOut);
         this.bnet.BeginReceiveFrom(this.bnetBuf, 0, 256, SocketFlags.None, ref this.epBnet,
            new AsyncCallback(this.Bnet_Receive), this.bnet);


In the asynchronous callback, I set up the BeginReceiveFrom call again.  I also have a trace method that says "Length of data received from bnet: x" where x is the length.  The BNLS server responds right; the async call only happens every so often, whenever the BNLS server responds.  However, the Bnet server goes into an infinite loop as soon as the BeginReceiveFrom() call begins.  Considering that they are setup exactly the same, I don't understand what is going wrong.

Also, I'm looking at my Ethereal packet capture when I connected to bnet with Starcraft.  It looks like 5 ports start sending and receiving data.  Are all 5 ports used?  I started with local port 3468 and then ports 3469-3472 all opened up.

Any ideas?

TIA,
--Rob
QuoteEvery generation of humans believed it had all the answers it needed, except for a few mysteries they assumed would be solved at any moment. And they all believed their ancestors were simplistic and deluded. What are the odds that you are the first generation of humans who will understand reality?

After 3 years, it's on the horizon.  The new JinxBot, and BN#, the managed Battle.net Client library.

Quote from: chyea on January 16, 2009, 05:05 PM
You've just located global warming.

Spht

#1
Quote from: Myndfyre on September 25, 2003, 11:25 AM
Guys, you have no idea how happy I am to finally get online with BNLS.  It's been a long time coming.  Thanks for all your help!

It turned out that static thing that you guys suggested before was right.  I ended up using an asyncrhonous Socket.ReceiveFrom() method pointing to the BNLS server and port.  Worked fine, and I'm communicating great with BNLS.

Here's what I'm doing:

         this.epBNLS = new IPEndPoint(Dns.Resolve("bnls.valhallalegends.com").AddressList[0], 9367);
         this.epBnet = new IPEndPoint(Dns.Resolve("useast.battle.net").AddressList[0], 6112);
         this.bnlsOut = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp);
         this.bnet = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp);
         this.bnet.Connect(this.epBnet);
         this.bnlsOut.Connect(this.epBNLS);


         this.bnlsOut.BeginReceiveFrom(this.bnlsBuf, 0, 256, SocketFlags.None, ref this.epBNLS,
            new AsyncCallback(this.Bnls_Receive), this.bnlsOut);
         this.bnet.BeginReceiveFrom(this.bnetBuf, 0, 256, SocketFlags.None, ref this.epBnet,
            new AsyncCallback(this.Bnet_Receive), this.bnet);


In the asynchronous callback, I set up the BeginReceiveFrom call again.  I also have a trace method that says "Length of data received from bnet: x" where x is the length.  The BNLS server responds right; the async call only happens every so often, whenever the BNLS server responds.  However, the Bnet server goes into an infinite loop as soon as the BeginReceiveFrom() call begins.  Considering that they are setup exactly the same, I don't understand what is going wrong.

Also, I'm looking at my Ethereal packet capture when I connected to bnet with Starcraft.  It looks like 5 ports start sending and receiving data.  Are all 5 ports used?  I started with local port 3468 and then ports 3469-3472 all opened up.

Any ideas?

TIA,
--Rob

As I've already told you, local ports are always changing. Set your capture to the remote port, 6112, which Starcraft uses to connect to Battle.net.

The other local ports you're seeing could be from UDP transfers (when Starcraft is verifying UDP support).

Skywing

You should allow the sockets provider to assign a local name to sockets when you are connecting to something in most cases; this is what Starcraft is doing.  Forcing the local name to use a particular port for an outbound connection in most cases is a bad idea and will cause problems, particularly if you try running >1 instance of your app.

MyndFyre

Quote
As I've already told you, local ports are always changing. Set your capture to the remote port, 6112, which Starcraft uses to connect to Battle.net.

The other local ports you're seeing could be from UDP transfers (when Starcraft is verifying UDP support).

I am using a remote port.  The IPEndPoint class initializes to the resolved useast.battle.net address, and then to the port 6112.  I then connect to Battle.net with the socket using that EndPoint, not knowing what local port I am connecting with.

I don't think the problem has to do with ports, per se, but that for whatever reason, I get stuck in an infinite loop when trying to asynchronously receive data.  The method I'm using works fine for BNLS, but not for Battle.net.
QuoteEvery generation of humans believed it had all the answers it needed, except for a few mysteries they assumed would be solved at any moment. And they all believed their ancestors were simplistic and deluded. What are the odds that you are the first generation of humans who will understand reality?

After 3 years, it's on the horizon.  The new JinxBot, and BN#, the managed Battle.net Client library.

Quote from: chyea on January 16, 2009, 05:05 PM
You've just located global warming.