Sign in

username:

password:



Not a member?

Search Comp.Arch.FPGA



Search tips

fpga by Keywords

Altera | ASIC | CPLD | Cyclone | DCM | DDR | DSP | Ethernet | ISE | JTAG | Linux | LVDS | Microblaze | ML310 | Modelsim | NIOS | OPB | PCI | Quartus | RocketIO | SDRAM | Spartan | Spartan3 | SRAM | Stratix | Verilog | VHDL | Virtex | Virtex-4 | Virtex-II | Xilinx | XST

Ads

See Also

DSPEmbedded SystemsElectronics

Comp.Arch.FPGA | Checking whether the client is connected to the Server

There are 1 messages in this thread.

You are currently looking at messages 0 to 1.

Checking whether the client is connected to the Server - micro - 2010-08-27 07:59:00

Hi, 
I am working on establishing Client-Server module over TCP.I have put a setup such that my PC acts as a normal server where I can connect it from someother PC's on my LAN using 'telnet ipaddress port' command and once I getconnected with the server and can give some input from client computer sothat it gets displayed on my server window(connection is established anddata exchange takes place). 
Until here I can say that the server is working fine and what i wanted toimplement is that now I wrote a code using lwIP API for the AltiumNanaboard so that my NB3000 acts like a client and i wanted it to getconnected to my PC Server. 
Here goes my code for the client part which gets connected to the Serverwith given IPaddress. 

int tcp_client(void) 
{ 
char data[] = "Hello World"; 
struct netconn *conn; 
struct ip_addr ServAddr; 
err_t err; 
u16_t port; 

port = 7777; 

conn = netconn_new(NETCONN_TCP); 

IP4_ADDR(&ServAddr, 192,168,xx,xxx); 

err = netconn_connect(conn, &ServAddr, port); 

printf("err = %d", err); // here I am getting err = -4 as output when Iprint it.

if(err == ERR_OK) 

netconn_write(conn, data, sizeof(data), NETCONN_NOCOPY); 

netconn_close(conn); 

netconn_delete(conn); 
} 
} 

here i open a new connection and connect it to Server using its IPaddress.

Before that I wanted to check the connection whether it is connected ornot, so what i did is i assigned a variable "err" and when I try to printit out on the terminal instrument and see the value it gives a value of"-4". 
Is this correct what I am doing here so that if i get a negative value thatmeans the client is successfully connected to the server. 
If so how can i transfer the data "Hello World" on to my server and get itdisplayed there. 
Kind Regards,
Greek	   
					
---------------------------------------		
Posted through http://www.FPGARelated.com