Skip to content

Commit

Permalink
no message
Browse files Browse the repository at this point in the history
  • Loading branch information
HAM-2015 committed Aug 22, 2020
1 parent feed38d commit 97afb1c
Showing 1 changed file with 12 additions and 3 deletions.
15 changes: 12 additions & 3 deletions CsGo/Go/socket.cs
Original file line number Diff line number Diff line change
Expand Up @@ -763,6 +763,7 @@ static public SocketError SendFile(Socket sck, SafeHandle fileHandle, long offse
}

Socket _socket;
EndPoint _localPoint;
socket_same_handler _readSameHandler;
socket_same_handler _writeSameHandler;
socket_ptr_handler _readPtrHandler;
Expand Down Expand Up @@ -888,11 +889,20 @@ public override void close()
catch (System.Exception) { }
}

public void bind(string ip)
{
_localPoint = null == ip ? null : new IPEndPoint(IPAddress.Parse(ip), 0);
}

public void async_connect(string ip, int port, Action<socket_result> cb)
{
try
{
_socket = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp);
if (null != _localPoint)
{
_socket.Bind(_localPoint);
}
_socket.BeginConnect(IPAddress.Parse(ip), port, delegate (IAsyncResult ar)
{
try
Expand Down Expand Up @@ -1200,14 +1210,13 @@ public bool resue
}
}

public bool bind(string ip, int port)
public bool bind(string ip, int port, int backlog = 1)
{
try
{
_socket.Bind(new IPEndPoint(IPAddress.Parse(ip), port));
_socket.Listen(1);
_socket.Listen(backlog);
return true;

}
catch (System.Exception) { }
return false;
Expand Down

0 comments on commit 97afb1c

Please sign in to comment.