- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi everyone!
I a Nios newbie, so I'm sorry if I'm asking any FAQ, but I can't find any information on the subject. I want to build a multiport socket server For example, imagine server which allows 3 connections: - port 23 which is a simple telnet terminal - port 6 which echoes back everything - port 1024 which bridges data to and from a serial port I started with the simple_server_socket template. Everything works fine as long as I listen only one of the above ports. If more than a port is listening, only the one whose task has higher priority will work; the others seems to connect but no data is transferred; then after a while a get a stream of "No free buffers for rx " error messages from the jtag debug port. Another issue I have is on connection closing. If the server closes it, there no problem and my client can reconnect. If the client closes the connection, the server doesn't recognize it and remain in a connected state. If I try to reconnect I get the same behaviour and errors as described above with a multiple connection. Thank you for any help RegardsLink Copied
3 Replies
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Further information:
The problems arises when I call select() for both sockets, waiting for a connection. The higher priority one works The lower priority one connects (the client is connected) but select() doesn't return and the data actually is not accepted. I tried to set the select() call non blocking (zero timeout) and inserting a TK_SLEEP() after it, as suggested in a previous post, but select() still blocks. Any ideas? On the other hand I solved the problem with connection closing: recv() was not tested for zero return values, indicating that the client closed the connection.- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I'd check your code against what is done in an enhanced version of the example that you used:
http://nioswiki.com/exampledesigns/simplesocketserverplus Also, the following looks _exactly_ like the issue that you're seeing: http://www.altera.com/support/kdb/solutions/rd11062009_597.html Cheers, - slacker- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Actually I had understood there was some sort of problem with the select() function, so I solved the problem with a non-blocking call and forcing a sleep if there's no data available from the socket.
i.e. : if (select(max_socket, &readfds, NULL, NULL, &tout) <= 0) { TK_SLEEP(5); continue; } with a zero tout. Now I will look at the patch you suggested which is probably better. Thank you for your help Slacker.
Reply
Topic Options
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page