Fixes to NetworkTest
This commit is contained in:
parent
da9bd55e06
commit
ec9c3399bf
2 changed files with 19 additions and 1 deletions
|
@ -462,7 +462,7 @@ void UDPC_update(UDPC_Context *ctx)
|
||||||
(struct sockaddr*) &receivedData,
|
(struct sockaddr*) &receivedData,
|
||||||
&receivedDataSize);
|
&receivedDataSize);
|
||||||
|
|
||||||
if(bytes == 0 && (errno == EAGAIN || errno == EWOULDBLOCK))
|
if(bytes == -1 && (errno == EAGAIN || errno == EWOULDBLOCK))
|
||||||
{
|
{
|
||||||
// expected result for non-blocking socket
|
// expected result for non-blocking socket
|
||||||
return;
|
return;
|
||||||
|
|
|
@ -10,12 +10,27 @@ void printUsage()
|
||||||
printf("Usage: [-c] -a <addr> -p <target_port> -l <listen_port>\n");
|
printf("Usage: [-c] -a <addr> -p <target_port> -l <listen_port>\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void conCallback(void *userdata, uint32_t addr)
|
||||||
|
{
|
||||||
|
*((int*)userdata) = 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
void discCallback(void *userdata, uint32_t addr)
|
||||||
|
{
|
||||||
|
*((int*)userdata) = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
void recCallback(void *userdata, char *data, uint32_t size)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
int main(int argc, char** argv)
|
int main(int argc, char** argv)
|
||||||
{
|
{
|
||||||
int isClient = 0;
|
int isClient = 0;
|
||||||
uint32_t targetAddress = 0;
|
uint32_t targetAddress = 0;
|
||||||
uint16_t targetPort = 0;
|
uint16_t targetPort = 0;
|
||||||
uint16_t listenPort = 0;
|
uint16_t listenPort = 0;
|
||||||
|
int isConnected = 0;
|
||||||
|
|
||||||
--argc; ++argv;
|
--argc; ++argv;
|
||||||
while(argc > 0)
|
while(argc > 0)
|
||||||
|
@ -51,6 +66,9 @@ int main(int argc, char** argv)
|
||||||
if(UDPC_get_error(ctx) == UDPC_SUCCESS)
|
if(UDPC_get_error(ctx) == UDPC_SUCCESS)
|
||||||
{
|
{
|
||||||
UDPC_set_logging_type(ctx, 4);
|
UDPC_set_logging_type(ctx, 4);
|
||||||
|
UDPC_set_callback_connected(ctx, conCallback, &isConnected);
|
||||||
|
UDPC_set_callback_disconnected(ctx, discCallback, &isConnected);
|
||||||
|
UDPC_set_callback_received(ctx, recCallback, NULL);
|
||||||
while(UDPC_get_error(ctx) == UDPC_SUCCESS)
|
while(UDPC_get_error(ctx) == UDPC_SUCCESS)
|
||||||
{
|
{
|
||||||
if(isClient)
|
if(isClient)
|
||||||
|
|
Loading…
Reference in a new issue