1. listen (sock, back)

When listen (sock, back) is active, existing communications sockets cannot work because there is no cpu time for them. Only one connection can be permitted.

Euphoria 4, MS Window Vista, win32lib, EU 4 sockets

Multitasking is used throughout.

new topic     » topic index » view message » categorize

2. Re: listen (sock, back)

FredRansom said...

When listen (sock, back) is active, existing communications sockets cannot work because there is no cpu time for them. Only one connection can be permitted.

Euphoria 4, MS Window Vista, win32lib, EU 4 sockets

Multitasking is used throughout.

This is a known limitation of the tasking system. In 4.0 we now use threads, but there is a big global lock so nearly all of the time only one thread is allowed to run. (On Unix (including Mac OS X) this issue is easily worked around by using fork() instead of tasks.)

new topic     » goto parent     » topic index » view message » categorize

3. Re: listen (sock, back)

I'm not familiar with threads in EU 4. Is their any documentation for them? Threads work fine in VB, C#, and C, so perhaps I can tweak the OS thread prioritization.

new topic     » goto parent     » topic index » view message » categorize

4. Re: listen (sock, back)

FredRansom said...

I'm not familiar with threads in EU 4. Is their any documentation for them? Threads work fine in VB, C#, and C, so perhaps I can tweak the OS thread prioritization.

Euphoria code does not use native threads. For non-Windows implementations of euphoria's multi-tasking system, pthreads were used to implement them. The windows implementation was done with fibers, which provide native cooperative multitasking.

The original method of switching between stacks didn't work with (at least) newer Linux kernels. I think that some anti-stack smashing features were responsible for the breakage.

Basically, we use threads and mutexes to ensure that only one task runs at any time.

As for using native threads with a euphoria program...there are issues with the euphoria back end that would currently prevent this from working. I suppose it might be possible to hack up some translated code that could be threaded, but even then, the runtime libraries aren't thread safe. I couldn't say if this will ever change.

Matt

new topic     » goto parent     » topic index » view message » categorize

5. Re: listen (sock, back)

Curious, can't you use select() to determine if a connection is waiting? Or is that just for read()?

It's been a while since I've used TCP. getlost

-Greg

new topic     » goto parent     » topic index » view message » categorize

6. Re: listen (sock, back)

The preferred command is poll. Just about every socket command has a blocking and non-blocking version that are named differently. Reviewing the documentation should help you find what you are looking for.

new topic     » goto parent     » topic index » view message » categorize

7. Re: listen (sock, back)

Didn't fine poll in the EU 4 documentation. Basically, right now it looks like either writing a dll in some other language or just not using EU 4 for server work. Also, client mode fails to act unless its window is in focus. Right now it appears that EU 4 is unsuitable for general tcp/ip use. Please let me know if there is a better way within EU 4.

new topic     » goto parent     » topic index » view message » categorize

8. Re: listen (sock, back)

FredRansom said...

Didn't fine poll in the EU 4 documentation. Basically, right now it looks like either writing a dll in some other language or just not using EU 4 for server work. Also, client mode fails to act unless its window is in focus. Right now it appears that EU 4 is unsuitable for general tcp/ip use. Please let me know if there is a better way within EU 4.

I've only worked with the Unix version of Eu 4 and sockets. Still, this behavior seems strange. poll() does not exist in Eu 4, but the Unix version of select() can be made nonblocking (this is controlled by the timeout parameter). Under Unix, listen() is nonblocking and does not wait at all. accept() is blocking, but with select() one can call accept() only when it is known that a connection is waiting to be made (such that accept() returns right away). The sockets code just uses winsock, so these are winsock oddities, bugs in the wrapper that Watcom C uses for winsock, or something very strange is going on here.

new topic     » goto parent     » topic index » view message » categorize

9. Re: listen (sock, back)

On MS Windows, using win32lib, listen does not return until it receives an incoming connection request.

new topic     » goto parent     » topic index » view message » categorize

10. Re: listen (sock, back)

FredRansom said...

On MS Windows, using win32lib, listen does not return until it receives an incoming connection request.

I didn't realize that win32lib had its own tcp/ip functions.

I recommend trying the functions in std/socket.e - you might have better luck with these.

new topic     » goto parent     » topic index » view message » categorize

11. Re: listen (sock, back)

Look at demo/chat_server.ex ... It is a multi-user chat server that accepts any number of connections all while maintaining communication with other connected clients. Basically, the main loop uses select to detect new incoming connections, incoming messages or clients that have disconnected. When a new connection exists, it calls accept and let's the other chatters know of the new person who just joined. When a new message comes in, the message is then sent to all connected clients. When a client disconnects, all remaining clients are sent a disconnect notice.

You can use chat_client.ex to communicate with the server. The idea was not to make a chat system but to show off select.

Maybe this is what you are looking for?

Jeremy

new topic     » goto parent     » topic index » view message » categorize

12. Re: listen (sock, back)

Yes, this is what I needed. I also came across a library that implements Windows asynchronous sockets directly.

The reason I want to use Euphoria in my particular application is that, although .net is twice as fast in straight number crunching, EU is 3 to 4 times as fast as .net when dealing with complex hierarchical data structures in spite of .net's arraylist that simulates EU sequences.

Thank you for your replies.

new topic     » goto parent     » topic index » view message » categorize

13. Re: listen (sock, back)

jimcbrown said...
FredRansom said...

On MS Windows, using win32lib, listen does not return until it receives an incoming connection request.

I didn't realize that win32lib had its own tcp/ip functions.

Win32lib does not have any TCP/IP functions in it.

new topic     » goto parent     » topic index » view message » categorize

Search



Quick Links

User menu

Not signed in.

Misc Menu