tcp/ip

Hi there, I'm working with socket programming to let an embedded linux system (TS-7200 board) deal with a windows-based client. After calling "socket", "bind" and "listen" I need to call "accept" to establish the connection between client and server. How can I accept a connection in non blocking mode? With fnctl I can set this mode for my own socket file descriptor and it works with the listen command, but how can I let my program work unblocked? I need to make differnt things while waiting for data to be ready to read on the ethernet. If data can come in asyncronously from different sources (ethernet, rs-485, rs-232) how can I determine which one to choose and when? Thanks, Marco

Reply to
Marco
Loading thread data ...

Some of many options:

You can use select() to wait on one of several resources.

You can create multiple processes by using fork() and communicate between them e.g. with system V message queues or sockets.

You can create multiple threads using the posix thread library. Here all threads can share the data memory, so that you don't need to transfer data from one to another. Posix threads are especially interesting when using Linux 2.6.x as the thread performance has been improved greatly (with 2.4 threads were justs processes that share memory pages).

-Michael

Reply to
Michael Schnell

Use select on the listen socket and then accept. Beej's famous guide shows this in detail:

formatting link

Best regards,

--
Bernhard Roessmann
Don't Fear The Penguins!
Reply to
Bernhard Roessmann

ElectronDepot website is not affiliated with any of the manufacturers or service providers discussed here. All logos and trade names are the property of their respective owners.