Skip to content

Commit

Permalink
Merge branch 'master' into dotnet8
Browse files Browse the repository at this point in the history
  • Loading branch information
zarlo authored Dec 12, 2023
2 parents dd2f82e + 3cddfe7 commit 1306c8f
Show file tree
Hide file tree
Showing 3 changed files with 57 additions and 14 deletions.
27 changes: 19 additions & 8 deletions source/Cosmos.System2/Network/IPv4/TCP/Tcp.cs
Original file line number Diff line number Diff line change
Expand Up @@ -282,11 +282,6 @@ public static void RemoveConnection(ushort localPort, ushort remotePort, Address

#endregion

/// <summary>
/// The RX buffer queue.
/// </summary>
public Queue<TCPPacket> RxBuffer;

/// <summary>
/// The connection status.
/// </summary>
Expand Down Expand Up @@ -575,9 +570,25 @@ public void ProcessEstablished(TCPPacket packet)

Data = ArrayHelper.Concat(Data, packet.TCP_Data);

RxBuffer.Enqueue(packet);
// Handle FIN flag within PSH handling if both are set
if (packet.FIN)
{
TCB.RcvNxt++;

SendEmptyPacket(Flags.ACK);
SendEmptyPacket(Flags.ACK);

Status = Status.CLOSE_WAIT;

HAL.Global.PIT.Wait(300);

SendEmptyPacket(Flags.FIN);

Status = Status.LAST_ACK;
}
else
{
SendEmptyPacket(Flags.ACK);
}
return;
}
else if (packet.FIN)
Expand All @@ -596,7 +607,7 @@ public void ProcessEstablished(TCPPacket packet)
TCB.RcvNxt += packet.TCP_DataLength;

Data = ArrayHelper.Concat(Data, packet.TCP_Data);
}
}
}
if (packet.RST)
{
Expand Down
37 changes: 37 additions & 0 deletions source/Cosmos.System2_Plugs/System/IO/OSFileStreamStrategyImpl.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using IL2CPU.API.Attribs;

namespace Cosmos.System_Plugs.System.IO
{
[Plug("System.IO.Strategies.OSFileStreamStrategy, System.Private.CoreLib")]
public class OSFileStreamStrategyImpl
{
public static void CCtor()
{
}

public static void SetLength(object aThis, long len)
{
throw new NotImplementedException();
}

public static long Seek(object aThis, long offset, object origin)
{
throw new NotImplementedException();
}

public static long get_Length(object aThis)
{
throw new NotImplementedException();
}

public static bool get_CanSeek(object aThis)
{
throw new NotImplementedException();
}
}
}
7 changes: 1 addition & 6 deletions source/Cosmos.System2_Plugs/System/Net/Sockets/SocketImpl.cs
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,6 @@ public static Socket Accept(Socket aThis)
private static void Start()
{
StateMachine = new((ushort)EndPoint.Port, 0, Cosmos.System.Network.IPv4.Address.Zero, Cosmos.System.Network.IPv4.Address.Zero);
StateMachine.RxBuffer = new Queue<TCPPacket>(8);
StateMachine.LocalEndPoint.Port = (ushort)EndPoint.Port;
StateMachine.Status = Status.LISTEN;

Expand Down Expand Up @@ -253,12 +252,10 @@ public static int Receive(Socket aThis, byte[] buffer, int offset, int size, Soc
if (StateMachine.Status != Status.ESTABLISHED)
{
Cosmos.HAL.Global.debugger.Send("Socket - Client must be connected before receiving data..");
return 0;
break;
}
}

StateMachine.RxBuffer.Dequeue();

int bytesToCopy = Math.Min(StateMachine.Data.Length, size);
Buffer.BlockCopy(StateMachine.Data, 0, buffer, offset, bytesToCopy);

Expand Down Expand Up @@ -309,8 +306,6 @@ public static void Close(Socket aThis, int timeout)
{
StateMachine.SendEmptyPacket(Flags.FIN | Flags.ACK);

StateMachine.TCB.SndNxt++;

StateMachine.Status = Status.FIN_WAIT1;

if (StateMachine.WaitStatus(Status.CLOSED, 5000) == false)
Expand Down

0 comments on commit 1306c8f

Please sign in to comment.