Files
XPlaneConnectCSP/MATLAB/+XPlaneConnect/clearUDPBuffer.m
2014-11-24 12:29:40 -08:00

33 lines
766 B
Matlab

function socket = clearUDPBuffer(socket,varargin)
% clearUDPBuffer Script that clears an UDP Socket Buffer by closing and
% reopening the socket
%
% Inputs
% Socket: UDP Socket to be cleared
%
% Outputs
% Socket: UDP Socket
%
% Use
% 1. import XPlaneConnect.*;
% 2. Socket = openUDP(49005);
% 3. Socket = clearUDPBuffer(Socket);
%
% Contributors
% [CT] Christopher Teubert (SGT, Inc.)
% christopher.a.teubert@nasa.gov
%
% To Do
% 1. Verify Input
%
% BEGIN CODE
import XPlaneConnect.*
%% Close and reopen socket
if ~socket.isClosed()
port = socket.getLocalPort(); %get port of socket
socket.close; %Close Socket
socket = openUDP(port,varargin); %open new socket
end
end