RecvDgram.c revision 4fd606d1f5abe38e1f42c38de1d2e895166bd0f4
/** @file
Receive a datagram
Copyright (c) 2011, Intel Corporation
All rights reserved. This program and the accompanying materials
are licensed and made available under the terms and conditions of the BSD License
which accompanies this distribution. The full text of the license may be found at
THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
**/
#include <errno.h>
#include <string.h>
#include <Uefi.h>
#include <unistd.h>
#include <Library/DebugLib.h>
/**
Receive a datagram
@param [in] Argc The number of arguments
@param [in] Argv The argument value array
@retval 0 The application exited normally.
@retval Other An error occurred.
**/
int
main (
)
{
struct sockaddr_in Address;
int s;
int Status;
DEBUG (( DEBUG_INFO,
"%a starting\r\n",
Argv[0]));
//
// Get the socket
//
if ( -1 == s ) {
}
else {
Status = setsockopt ( s,
&Timeout,
sizeof ( Timeout ));
if ( -1 == Status ) {
}
else {
AddressLength = sizeof ( Address );
LengthInBytes = recvfrom ( s,
&mBuffer[0],
sizeof ( mBuffer[0]),
0,
&AddressLength );
if ( -1 == LengthInBytes ) {
Print ( L"No datagram received\r\n" );
}
else {
}
}
else {
Print ( L"Received %d bytes from %d.%d.%d.%d:%d\r\n",
}
}
//
// Done with the socket
//
close ( s );
}
//
// All done
//
DEBUG (( DEBUG_INFO,
"%a exiting, errno: %d\r\n",
Argv[0],
errno ));
return errno;
}