OobTx.c revision 4fd606d1f5abe38e1f42c38de1d2e895166bd0f4
/** @file
Windows version of the OOB Transmit application
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 <OobTx.h>
/**
Transmit out-of-band messages to the remote system.
@param [in] ArgC Argument count
@param [in] ArgV Argument value array
@retval 0 Successfully operation
**/
int
OobTx (
)
{
struct sockaddr_in LocalPort;
struct sockaddr_in RemotePort;
int RetVal;
SOCKET s;
//
// Create the socket
//
if ( -1 == s ) {
}
else {
//
//
for ( ; ; ) {
//
// Validate the arguments
//
if (( 2 > ArgC )
"%d.%d.%d.%d",
&RemoteAddress[0],
&RemoteAddress[1],
&RemoteAddress[2],
&RemoteAddress[3]))
|| ( 224 < RemoteAddress[0])
|| (( 0 == RemoteAddress[0])
&& ( 0 == RemoteAddress[1])
&& ( 0 == RemoteAddress[2])
&& ( 0 == RemoteAddress[3]))) {
break;
}
//
// Bind the socket to a local port
//
sizeof ( LocalPort ));
if ( -1 == RetVal ) {
break;
}
//
// Specify the remote port
//
| RemoteAddress[0];
//
// Connect to the remote server
//
if ( -1 == RetVal ) {
break;
}
//
// Select the OOB processing
//
RetVal = setsockopt ( s,
(char *)&OobInLine,
sizeof ( OobInLine ));
if ( -1 == RetVal ) {
break;
}
: "OOB messages move to the head of the queue" );
//
// Initialize the messages
//
//
// Send the data before the out-of-band message
//
TransmittedBefore = 0;
BytesSent = 0;
do {
BytesTransmitted = send ( s,
0 );
if ( -1 == BytesTransmitted ) {
break;
}
RetVal = 0;
if ( 0 != RetVal ) {
break;
}
}
if ( 0 != RetVal ) {
break;
}
//
// Send the out-of-band message
//
BytesSent = 0;
do {
BytesTransmitted = send ( s,
MSG_OOB );
if ( -1 == BytesTransmitted ) {
break;
}
RetVal = 0;
if ( 0 != RetVal ) {
break;
}
//
// Send the data after the out-of-band message
//
TransmittedAfter = 0;
BytesSent = 0;
do {
BytesTransmitted = send ( s,
0 );
if ( -1 == BytesTransmitted ) {
break;
}
RetVal = 0;
if ( 0 != RetVal ) {
break;
}
}
//
// Test completed successfully
//
if ( 0 == RetVal ) {
printf ( " --------\r\n" );
+ TransmittedAfter );
}
break;
}
//
// Close the socket
//
CLOSE_SOCKET ( s );
}
//
// Return the operation status
//
return RetVal;
}