mirror of
https://github.com/Sanae6/SmoOnlineServer.git
synced 2024-11-10 13:45:06 +00:00
Try using tcp to not require sudo?
This commit is contained in:
parent
886b57f16a
commit
cc5c86091e
2 changed files with 4 additions and 4 deletions
|
@ -17,7 +17,7 @@ public class Server {
|
|||
|
||||
public async Task Listen(CancellationToken? token = null) {
|
||||
Socket serverSocket = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp);
|
||||
serverSocket.SetSocketOption(SocketOptionLevel.Socket, SocketOptionName.ReuseAddress, true);
|
||||
serverSocket.SetSocketOption(SocketOptionLevel.Tcp, SocketOptionName.ReuseAddress, true);
|
||||
serverSocket.Bind(new IPEndPoint(IPAddress.Parse(Settings.Instance.Server.Address), Settings.Instance.Server.Port));
|
||||
serverSocket.Listen();
|
||||
|
||||
|
@ -26,7 +26,7 @@ public class Server {
|
|||
try {
|
||||
while (true) {
|
||||
Socket socket = token.HasValue ? await serverSocket.AcceptAsync(token.Value) : await serverSocket.AcceptAsync();
|
||||
socket.SetSocketOption(SocketOptionLevel.Socket, SocketOptionName.NoDelay, true);
|
||||
socket.SetSocketOption(SocketOptionLevel.Tcp, SocketOptionName.NoDelay, true);
|
||||
|
||||
Logger.Warn($"Accepted connection for client {socket.RemoteEndPoint}");
|
||||
|
||||
|
|
|
@ -78,7 +78,7 @@ async Task S(string n, Guid otherId, Guid ownId) {
|
|||
}
|
||||
if (type == PacketType.Player) {
|
||||
Task.Run(async () => {
|
||||
await Task.Delay(2000);
|
||||
await Task.Delay(1000);
|
||||
header.Id = ownId;
|
||||
MemoryMarshal.Write(owner.Memory.Span[..Constants.HeaderSize], ref header);
|
||||
await stream.WriteAsync(owner.Memory[..(Constants.HeaderSize + header.PacketSize)]);
|
||||
|
@ -94,7 +94,7 @@ async Task S(string n, Guid otherId, Guid ownId) {
|
|||
}
|
||||
|
||||
Guid temp = baseOtherId;
|
||||
IEnumerable<Task> stuff = Enumerable.Range(0, 3).Select(i => {
|
||||
IEnumerable<Task> stuff = Enumerable.Range(0, 7).Select(i => {
|
||||
byte[] tmp = temp.ToByteArray();
|
||||
tmp[0]++;
|
||||
Guid newOwnId = new Guid(tmp);
|
||||
|
|
Loading…
Reference in a new issue