问题
I am currently developping an application that performs a TCP/IP communication between an atmel AT91SAM7x256 microcontroller, and my Windows machine.
I have successfully compiled and linked the uIP standard library to my application. The uIP functions are getting recognized by the application, but the first thing I do in the main, for the application to listen to a connection request on port 51719 is:
#include <stdio.h>
#include "uip.h"
#define UIP_APPCALL client_app
int main(void)
{
printf("Hello World ");
uip_init();
printf("Establishing connection\n");
uip_listen(HTONS(51719));
if(uip_connected())
{
printf("Connection established\n");
}
return 0;
}
But the program seems to skip the listening part because it simply prints hello world and establishing connection before exiting. I would have thought that because of the uip_listen()
function, that the program would go into a sort of infinite loop while waiting for a connection request (that is how the full stack TCP/IP library, winsock, handles things).
Is this not the correct way to listen for a connection on a certain port using the uIP library? I would appreciate any help!
UPDATE
I've tried inserting the listening in a while
loop:
printf("Establishing connection\n");
int c;
while(1)
{
uip_listen(HTONS(51719));
if(c = uip_connected() != 0)
{
printf("Connection established\n");
break;
}
But it still won't connect from the remost host.
}
来源:https://stackoverflow.com/questions/23496880/uip-listen-function-not-waiting-to-listen-for-connections-uip-library