1. Strange socket behavior on Windows

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

new topic     » topic index » view message » categorize

2. Re: Strange socket behavior on Windows

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 

.

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

Search



Quick Links

User menu

Not signed in.

Misc Menu