1. Strange socket behavior on Windows
- Posted by ghaberek (admin) Mar 04, 2016
- 1548 views
I wrote the following app to grab the Nagios client (really Check_MK) output via port 6556. (That may not be entirely relevant here.)
What I noticed is that, when I run this with eui.exe on Windows, I only ever get the first 15 bytes from the socket. It seems to be truncated at the first line feed character. I get "<<<check_mk>>>" and nothing more.
Further calls to select() and receive() result in no more data. And when I use euiw.exe, I have to force the console to be displayed to get all of the data, otherwise I have the same problem.
include std/console.e include std/error.e include std/os.e include std/socket.e sequence address = "192.168.1.136" integer port = 6556 function can_read( socket s, integer timeout = 0, integer timeout_micro = 0 ) sequence status = sockets:select( {s}, {s}, {s}, timeout, timeout_micro ) return status[1][SELECT_IS_READABLE] end function procedure main() socket s = sockets:create( AF_INET, SOCK_STREAM, 0 ) atom result = sockets:connect( s, address, port ) if result != 0 then error:crash( "connect() failed" ) end if console:display( "" ) -- output required? sequence data = sockets:receive( s ) while can_read( s ) do data &= sockets:receive( s ) end while console:display( data ) console:display( "length = []", length(data) ) sockets:close( s ) maybe_any_key() end procedure main()
Edit: I am testing this on Windows 10 Pro 64-bit with Euphoria 4.1 32-bit struct branch.
C:\>ver Microsoft Windows [Version 10.0.10586] C:\>eui -v Euphoria Interpreter v4.1.0 development 32-bit Windows, Using System Memory Revision Date: 2015-02-13 18:10:12, Id: 6318:1c30095180a0
-Greg
2. Re: Strange socket behavior on Windows
- Posted by SDPringle Mar 05, 2016
- 1432 views
Why don't you CD to a checked out version of Euphoria and run the socket test:
cd tests eutest -eui ../source/build/eui t_socket.e
.