Thanks! I see now. I overlooked the outer while loop. Thomas Rognon
On Mon, Aug 18, 2014 at 3:11 AM, Ye, Ting <ting...@intel.com> wrote: > Hi, > > > > TcpIoReceive() library function is defined to receive required amount of > data in a specified period, see the function description in TcpIoLib.h: > > > > @retval EFI_TIMEOUT Failed to receive the required amount of > data in the > > specified time period. > > > > When you set the required data length to 1024 bytes, this function will > first receive the packet less than 1024 bytes then wait for the next > packet. If this function cannot receive 1024 bytes data in total, it will > return EFI_TIMEOUT. > > > > > > In your case, if you want to receive the packet with less than 1024 bytes > length only, please use Tcp4->Receive () directly. Take TcpIoReceive() > function as reference: > > > > RxData->DataLength = 1024; > > Status = Tcp4->Receive (Tcp4, &TcpIo->RxToken.Tcp4Token); > > > > For instance, when a packet with 1000 bytes length is received during this > call, the ‘Status’ field will be set to EFI_SUCCESS and RxData->DataLength > will be set to 1000, and also, the TcpIoCommonNotify() will be signaled > thus TcpIo->IsRxDone will be set to TRUE. > > > > Best Regards, > > Ye Ting > > > > > > *From:* Ye, Ting [mailto:ting...@intel.com] > *Sent:* Monday, August 18, 2014 3:33 PM > *To:* edk2-devel@lists.sourceforge.net > *Subject:* Re: [edk2] TcpIoReceive question > > > > Hi, > > > > Thanks for reporting this. We will check whether we can reproduce the > issue. > > > > Best Regards, > > Ye Ting > > > > *From:* Thomas Rognon [mailto:tcrog...@gmail.com] > *Sent:* Sunday, August 17, 2014 8:21 AM > *To:* edk2-devel > *Subject:* [edk2] TcpIoReceive question > > > > I'm receiving a packet of unknown length and it is less than 1024 bytes. > I'm using TcpIoReceive. I'm expecting it to receive the packet and then > update the NET_FRAGMENT.Len to the number of bytes received. Instead, it > times out. > > > > I know the packet is being sent (I can see it on wireshark). Also, if the > actual packet size and my buffer size match, then everything works fine. It > only times out when the actual packet size is smaller than my buffer. > > > > Here is example code. What am I doing wrong? > > > > EFI_STATUS > > ExampleReceive ( > > IN EXAMPLE_PRIVATE *Private, > > IN OUT UINT32 *DataSize, > > IN OUT UINT8 *Data > > ) > > { > > EFI_STATUS Status; > > NET_FRAGMENT Fragment; > > NET_BUF *Packet; > > > > Fragment.Len = *DataSize; > > Fragment.Bulk = Data; > > Packet = NetbufFromExt ( > > &Fragment, > > 1, > > 0, > > 0, > > ExampleNbufExtFree, > > NULL > > ); > > if (Packet == NULL) { > > return EFI_OUT_OF_RESOURCES; > > } > > > > Status = gBS->SetTimer ( > > Private->RxTimeoutEvent, > > TimerRelative, > > 5 * TICKS_PER_SECOND > > ); > > if (EFI_ERROR (Status)) { > > NetbufFree (Packet); > > return Status; > > } > > > > Status = TcpIoReceive ( > > &Private->TcpIo, > > Packet, > > FALSE, > > Private->RxTimeoutEvent > > ); > > > > gBS->SetTimer (Private->RxTimeoutEvent, TimerCancel, 0); > > NetbufFree (Packet); > > > > if (!EFI_ERROR (Status)) { > > *DataSize = Fragment.Len; > > } > > > > return Status; > > } > > > > If the incoming packet is 1024 bytes, then the following code will work as > expected. If the incoming packet is less than 1024 bytes, then it will > return EFI_TIMEOUT after 5 seconds. > > > > DataSize = 1024; // this number is arbitrary > > Data = AllocatePool (DataSize); > > ExampleReceive (Private, &DataSize, Data); > > > > If I'm doing something wrong, then how would I receive a packet where I > know the maximum size, but I don't know the exact size? I'm using > UDK2010.SR1.UP1.P1. Thank you for any insight. > > > > Thomas Rognon > > > ------------------------------------------------------------------------------ > > _______________________________________________ > edk2-devel mailing list > edk2-devel@lists.sourceforge.net > https://lists.sourceforge.net/lists/listinfo/edk2-devel > >
------------------------------------------------------------------------------
_______________________________________________ edk2-devel mailing list edk2-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/edk2-devel