Network on Win98: failed - socket - no error ??

I'm playing with the Network library (the recommended portable way?) and have a surprising problem with a simple client/server example. As the same program works fine on Solaris and Win2k, I suspect its a standard "feature" and someone here with more network programming experience might be able to enlighten me? - Server: listenOn port, then accept handle and enter loop, echoing from handle to stdout - Client: connectTo "localhost" port, then enter loop echoing from stdin to handle Both programs work on Solaris and Win2k, but fail on Win98, with: Fail: failed Action: socket Reason: No error which would be merely amusing, I guess, if I knew what it meant, and what to do about it? Cheers, Claus

Did you remember to use 'withSocketsDo'? If you
did, it would help to see the code that's failing
for you (trivial or not.)
--sigbjorn
----- Original Message -----
From: "Claus Reinke"
I'm playing with the Network library (the recommended portable way?) and have a surprising problem with a simple client/server example. As the same program works fine on Solaris and Win2k, I suspect its a standard "feature" and someone here with more network programming experience might be able to enlighten me?
- Server: listenOn port, then accept handle and enter loop, echoing from handle to stdout - Client: connectTo "localhost" port, then enter loop echoing from stdin to handle
Both programs work on Solaris and Win2k, but fail on Win98, with:
Fail: failed Action: socket Reason: No error
which would be merely amusing, I guess, if I knew what it meant, and what to do about it?
Cheers, Claus
_______________________________________________ Glasgow-haskell-users mailing list Glasgow-haskell-users@haskell.org http://www.haskell.org/mailman/listinfo/glasgow-haskell-users

Did you remember to use 'withSocketsDo'? If you did, it would help to see the code that's failing for you (trivial or not.)
Did. But you're right, of course, so here's the current code. Claus -- Server.hs module Main where import Network import IO import System main = withSocketsDo $ do (pnum:_) <- getArgs let p = fromIntegral $ read pnum s <- listenOn $ PortNumber p (h, host, portnr) <- accept s hSetBuffering h LineBuffering loop h where loop h = do l <- hGetLine h putStrLn $ "SERVER: "++l loop h -- Client.hs module Main where import Network import IO import System main = withSocketsDo $ do (pnum:_) <- getArgs let p = fromIntegral $ read pnum h <- connectTo "localhost" $ PortNumber p hSetBuffering h LineBuffering loop h where loop h = do l <- getLine putStrLn $ "CLIENT: "++l hPutStrLn h l loop h
----- Original Message ----- From: "Claus Reinke"
To: Sent: Monday, March 03, 2003 04:14 Subject: Network on Win98: failed - socket - no error ?? I'm playing with the Network library (the recommended portable way?) and have a surprising problem with a simple client/server example. As the same program works fine on Solaris and Win2k, I suspect its a standard "feature" and someone here with more network programming experience might be able to enlighten me?
- Server: listenOn port, then accept handle and enter loop, echoing from handle to stdout - Client: connectTo "localhost" port, then enter loop echoing from stdin to handle
Both programs work on Solaris and Win2k, but fail on Win98, with:
Fail: failed Action: socket Reason: No error
which would be merely amusing, I guess, if I knew what it meant, and what to do about it?
Cheers, Claus
_______________________________________________ Glasgow-haskell-users mailing list Glasgow-haskell-users@haskell.org http://www.haskell.org/mailman/listinfo/glasgow-haskell-users
_______________________________________________ Glasgow-haskell-users mailing list Glasgow-haskell-users@haskell.org http://www.haskell.org/mailman/listinfo/glasgow-haskell-users

Still looking for inspirations on this one. I'm not at all sure I interpret the chain
of indirections in the CVS sources correctly, but Network.Socket uses
throwErrnoIfMinus1Retry, which does indeed try to use errno to figure out
what went wrong. Is that redirected anywhere for windows?
Because, in their infinite wisdom, the designers of Windows Sockets have
decided that errno isn't the way:
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/winsock/win...
_errno_and_wsagetlasterror_2.asp
Platform SDK: Windows Sockets 2
Error Codes - errno, h_errno and WSAGetLastError
Error codes set by Windows Sockets are not made available through the errno variable.
Additionally, for the getXbyY class of functions, error codes are not made available through the
h_errno variable. Instead, error codes are accessed by using the WSAGetLastError function. This
function is provided in Windows Sockets as a precursor (and eventually an alias) for the Microsoft®
Windows® function GetLastError. This is intended to provide a reliable way for a thread in a
multithreaded process to obtain per-thread error information.
...
Just trying to make sure that I'm worrying about the "right" error message..
Cheers,
Claus
----- Original Message -----
From: "Claus Reinke"
I'm playing with the Network library (the recommended portable way?) and have a surprising problem with a simple client/server example. As the same program works fine on Solaris and Win2k, I suspect its a standard "feature" and someone here with more network programming experience might be able to enlighten me?
- Server: listenOn port, then accept handle and enter loop, echoing from handle to stdout - Client: connectTo "localhost" port, then enter loop echoing from stdin to handle
Both programs work on Solaris and Win2k, but fail on Win98, with:
Fail: failed Action: socket Reason: No error
which would be merely amusing, I guess, if I knew what it meant, and what to do about it?
Cheers, Claus
_______________________________________________ Glasgow-haskell-users mailing list Glasgow-haskell-users@haskell.org http://www.haskell.org/mailman/listinfo/glasgow-haskell-users
participants (2)
-
Claus Reinke
-
Sigbjorn Finne