EDAboard.com | EDAboard.eu | EDAboard.de | EDAboard.co.uk | RTV forum PL | NewsGroups PL

TCP Client using lwIP API

elektroda.net NewsGroups Forum Index - FPGA - TCP Client using lwIP API

micro
Guest

Sat Aug 21, 2010 2:38 am   



Hi,
I am really looking for some help in how to write code for my FPGA boar
for implementing a TCP Client using lwIP API using the commands lik
netconn_connect() and so on. I found some documentation on how to build
TCP server but I could not find any help for TCP client. Any help regardin
on how to build a client would be great. If any body has an idea regardin
one of teh three topics which i have mentioned below, then that would b
helping me a lot:

1)I am looking for some basic explanation like what are the steps i need t
consider to write a client code from scratch.

2)or a sample code which shows the basic implementation of TCP client usin
lwIP API

3)or what changes should I need to make in the server program so that i
can run as a client

Kind Regards,
Mahee



---------------------------------------
Posted through http://www.FPGARelated.com

Marc Jet
Guest

Mon Aug 23, 2010 11:43 am   



The easiest way I found for that, is to use the socket API.

The CONNECT code looks similar to this:

struct sockaddr_in sServer;
sServer.sin_len = sizeof(struct sockaddr_in);
sServer.sin_family = AF_INET;
sServer.sin_port = MY_PORT_NUMBER;
inet_aton("123.45.123.45", &(sServer.sin_addr));
memset(&(sServer.sin_zero), 0, sizeof(sServer.sin_zero));

int nSocket = lwip_socket(AF_INET, SOCK_STREAM, IPPROTO_TCP);
if (nSocket < 0) {
printf("lwip_socket() returned -%d\r\n", -nSocket);
return;
}

printf("Connecting to server\r\n");

int nErr = lwip_connect(nSocket, (struct sockaddr*)(&sServer),
sizeof(sServer));
if (nErr < 0) {
printf("lwip_connect() returned -%d, errno=%d\r\n", -nErr,
lwip_get_err(nSocket));
return;
}

After that, you can use lwip_send() and lwip_recv() for data
transmission.

Best regards

elektroda.net NewsGroups Forum Index - FPGA - TCP Client using lwIP API

Arabic versionBulgarian versionCatalan versionCzech versionDanish versionGerman versionGreek versionEnglish versionSpanish versionFinnish versionFrench versionHindi versionCroatian versionIndonesian versionItalian versionHebrew versionJapanese versionKorean versionLithuanian versionLatvian versionDutch versionNorwegian versionPolish versionPortuguese versionRomanian versionRussian versionSlovak versionSlovenian versionSerbian versionSwedish versionTagalog versionUkrainian versionVietnamese versionChinese version
RTV map EDAboard.com map News map EDAboard.eu map EDAboard.de map EDAboard.co.uk map Opony