Created
October 1, 2015 01:24
-
-
Save KennethanCeyer/77015af6ecc7dd924eb9 to your computer and use it in GitHub Desktop.
C# Socket bind ip from the dns domain name.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
IPAddress bnetServerIP = Dns.GetHostAddresses(bnetConInfo["ip"])[0]; | |
IPEndPoint bnetServerEP = new IPEndPoint(bnetServerIP, Int32.Parse(bnetConInfo["port"])); | |
this.bnetSock = new Socket(AddressFamily.InterNetwork, SocketType.Dgram, ProtocolType.Udp); | |
byte[] receiveBuffer = new byte[255]; | |
try | |
{ | |
this.bnetSock.ReceiveBufferSize = Int32.MaxValue; | |
this.bnetSock.ReceiveTimeout = 3000; | |
this.getHandleMsg(BnetCode.ConnectionWithServer); | |
} | |
catch (Exception e) | |
{ | |
this.getHandleMsg(BnetCode.ConnectionSuccess); | |
} | |
this.bnetSock.Connect(bnetServerEP); | |
this.bnetSock.Send(BitConverter.GetBytes(0x01)); | |
this.getHandleMsg(BnetCode.ConnectionSuccess); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment