Nios® V/II Embedded Design Suite (EDS)
Support for Embedded Development Tools, Processors (SoCs and Nios® V/II processor), Embedded Development Suites (EDSs), Boot and Configuration, Operating Systems, C and C++

TCP connection example

Altera_Forum
Honored Contributor II
983 Views

I made this post earlier under the microC-subject, however, I would also be interesting in a general standalone example using lwIP. 

 

I am trying to make a TCP connection to a server with a nios II dev board. Does anyone have an example code on how that is done. I have tried with the following code with failing results, I think it has something to do with the destination IP. 

The destination address is 192.168.1.2 which is set below. 

 

conn_sock = socket(AF_INET, SOCK_STREAM, 0); 

addr2.sin_family = AF_INET; 

addr2.sin_port = htons(5824); 

addr2.sin_addr.s_addr = inet_addr("192.168.1.2"); 

connect(conn_sock, (struct sockaddr *)&addr2, sizeof(struct sockaddr_in)); 

send(conn_sock, buf, strlen(buf), 0); 

close(conn_sock);  

 

Cheers. /E
0 Kudos
3 Replies
Altera_Forum
Honored Contributor II
278 Views

 

--- Quote Start ---  

originally posted by bigmickey@Feb 2 2006, 10:24 AM 

http://forum.niosforum.com/forum/index.php?showtopic=949 (http://forum.niosforum.com/forum/index.php?showtopic=949

 

is what you need 

<div align='right'><{post_snapback}> (index.php?act=findpost&pid=12502) 

--- quote end ---  

 

--- Quote End ---  

 

 

I am looking for an example that makes a TCP connection under uC/OSII, the only examples I have found are servers and perhaps some UDP-broadcast. 

 

Allthough I have managed to make a UDP send to a particular IP by using: inet_addr("123.123.123.123") 

 

Still no luck for the TCP one. 

 

/E
0 Kudos
Altera_Forum
Honored Contributor II
278 Views

 

--- Quote Start ---  

originally posted by enil@Jan 24 2006, 04:12 PM 

i would also be interesting in a general standalone example using lwip. 

--- Quote End ---  

 

 

 

And so i thought for no operating system. 

You can see on altera site for simple_socket_server perhaps
0 Kudos
Reply