Skip to content

Commit

Permalink
support ipv6 only.
Browse files Browse the repository at this point in the history
  • Loading branch information
jarjin2000 committed Jul 4, 2017
1 parent 295c974 commit 3783177
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 5 deletions.
20 changes: 15 additions & 5 deletions Assets/LuaFramework/Scripts/Network/SocketClient.cs
Original file line number Diff line number Diff line change
Expand Up @@ -48,11 +48,21 @@ public void OnRemove() {
/// </summary>
void ConnectServer(string host, int port) {
client = null;
client = new TcpClient();
client.SendTimeout = 1000;
client.ReceiveTimeout = 1000;
client.NoDelay = true;
try {
IPAddress[] address = Dns.GetHostAddresses(host);
if (address.Length == 0) {
Debug.LogError("host invalid");
return;
}
if (address[0].AddressFamily == AddressFamily.InterNetworkV6) {
client = new TcpClient(AddressFamily.InterNetworkV6);
}
else {
client = new TcpClient(AddressFamily.InterNetwork);
}
client.SendTimeout = 1000;
client.ReceiveTimeout = 1000;
client.NoDelay = true;
client.BeginConnect(host, port, new AsyncCallback(OnConnect), null);
} catch (Exception e) {
Close(); Debug.LogError(e.Message);
Expand Down Expand Up @@ -81,7 +91,7 @@ void WriteMessage(byte[] message) {
writer.Write(message);
writer.Flush();
if (client != null && client.Connected) {
//NetworkStream stream = client.GetStream();
//NetworkStream stream = client.GetStream();
byte[] payload = ms.ToArray();
outStream.BeginWrite(payload, 0, payload.Length, new AsyncCallback(OnWrite), null);
} else {
Expand Down
1 change: 1 addition & 0 deletions ReadMe.txt
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ Excel配置:https://github.com/sy-yanghuan/proton
//-------------2017-07-05-------------
(1)重新编译luajit二进制文件到最新版本。
(2)替换Lua代码中Unity5.6.x废弃FindChild到Find函数。
(3)support ipv6 only.

//-------------2017-07-04-------------
(1)更新luajit二进制文件到最新版本。
Expand Down

0 comments on commit 3783177

Please sign in to comment.