TCP Client problem
Ethernet Chips
No replies yet. Be the first to reply.
Join the discussion.
Ethernet Chips
No replies yet. Be the first to reply.
Join the discussion.
Share projects and connect with makers.
Joined before the site update? first.
New to WIZnet Makers?
We sent a verification link to your address. Open it to activate your account, then log in.
Accounts from this email provider are reviewed by an administrator after verification. Approval usually takes one business day.
Already have an account?
Enter your email address. If it belongs to an account, we'll send a link to set a new password. Members who joined before the site update use this to set their password.
If an account uses that address, we sent a link to set a new password. The link works once and expires in 30 minutes.
Know your password?
Need an account?
RE: TCP Client problem
by Edward ·
Hi.
What kind using complie & IDE tool?
And what using example code?
I think… code problem…
Please tell me the example code.
Thank you
RE: TCP Client problem
by ronnie91 ·
Edward, I send example code to your email. I’m using crossstudio for ARM 3.5.
RE: TCP Client problem
by Edward ·
Hi.
where are downloaded from this exmaple code?
And I need main code.
Thank you
RE: TCP Client problem
by ronnie91 ·
Ok, here is a program in C++.
Thank you for your attention.
RE: TCP Client problem
by ronnie91 ·
I have one more question. Is it possible to simultaneously operate two sockets: one like a server, the second like a client?
RE: TCP Client problem
by Eugeny ·
Yes.
You need to ensure you write correct gateway address. When you issue connect request command for W5200, it sends ARP request to gateway. If gateway is not functional process terminates.
In general you should have the following fields properly preset for client mode:
Your settings
char mac[6]={0x00,0x16,0x59,0x00,0x00,0x00}; ethPort = 5555; char ip_addr[4]; char subnet_mask[4]; char gateway[4]; gateway[0] = 10; gateway[1] = 10; gateway[2] = 254; gateway[3] = 254; subnet_mask[0] = 255; subnet_mask[1] = 255; subnet_mask[2] = 0; subnet_mask[3] = 0; ip_addr[0] = 10; ip_addr[1] = 10; ip_addr[2] = 20; ip_addr[3] = 5;and
uint8 _ipp[4] = {10,10,20,30}; unsigned int _port = 5555;seem to be fine as far as I understand it, you connect ports 5555 at both ends, the only question is if 10.10.254.254 is functional as gateway.
What debug output says?
RE: TCP Client problem
by ronnie91 ·
Eugeny! Thank you for all your support. It was hardware problem. Now it’s works. But i have one more question. I can send data, but when terminal wasn’t open program don’t go in connect function to this function:
if (getSn_IR(s) & Sn_IR_TIMEOUT) { IINCHIP_WRITE(Sn_IR(s), (Sn_IR_TIMEOUT)); // clear TIMEOUT Interrupt ret = 0; break; }only goes on. But it’s works.
And secondly, when i open terminal for the first time client always connect to server in any time. Then I disable the terminal, and when i want to open the terminal within a few seconds, client always connects to the server. But when i wait not few seconds, but few minutes it does’t want to connect to the server. Any ideas where is a problem?
RE: TCP Client problem
by Eugeny ·
If you try to connect to device without it waiting for connection on specific port you will not connect anywhere and the device you are trying to connect from will timeout: getSn_IR(s) & Sn_IR_TIMEOUT will become true (timeout bit will be set to 1 in socket’s interrupt register).
Not sure I understand the second question.
RE: TCP Client problem
by ronnie91 ·
I will try explain my problem one more time. In function connect after function
when i turn on in terminal LISTEN i schould go to this function
or when I don’t listen a port, after few timeouts I schould go to this function
But my problem is that the program don’t go to neither function. But when I listen the port, I link to the server, because in terminal I could receive the data. Summing up it works, because in terminal I have connection, in eth_loop_tcpc - program after reading register (getSn_SR(s)) go to case: SOCK_ESTABLISHED, but and it is the problem in function connect() program don’t go to this function -
in spite of the program works.
RE: TCP Client problem
by Eugeny ·
I am sorry I hardly understand what you ask.
Regardless of your socket listening or actively connecting, after successful connection process, status register gets value of 0x17 (“established”). This is persistent state which will be there until any of connection participants decide to disconnect or there will be hardware failure on the line.
Timeout occurs when W5200 did not get any response from remote device for its network request. Timeout will NOT occur if remote devices respond to W5200 (whatever response it will be).
Synsent 0x15 is a transient state leading to either established state 0x17 through synreceive 0x16, or to disconnection 0x00. W5200 will go through this state when you instruct it to connect, or if there’s incoming connection for listening socket.
The most important for you is that you can send and receive information only in “established” 0x17 state (for TCP sockets). All other transient states of W5200 are important for troubleshooting purposes when something goes wrong and you do not reach 0x17.