Author | Message | Time |
---|---|---|
Myndfyr | 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: [code] 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); [/code] 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 | September 25, 2003, 4:25 PM |
Spht | [quote author=Myndfyre link=board=17;threadid=2819;start=0#msg22141 date=1064507156] 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: [code] 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); [/code] 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 [/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). | September 25, 2003, 4:44 PM |
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. | September 25, 2003, 5:44 PM |
Myndfyr | [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). [/QUOTE] 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. | September 25, 2003, 6:40 PM |