Sockets on Windows

Steinitz, Dominic J
23 Feb 2001 11:09:34 Z

Content-Type: text/plain; charset=us-ascii
Content-Transfer-Encoding: Quoted-Printable
Content-Disposition: inline

I am was trying out sockets. These worked fine under linux. Under windows I=
 get the following error. Does anyone know what it means and how I can fix =
it? I can telnet from within the cygwin window so I assume tcp/ip is runnin=

Thanks, Dominic.

administrator@DEFAULT /cygdrive/d/dom/home/socketTest
$ ./server1 8000

Fail: does not exist
Action: getProtocolByName
Reason: no such protocol entry

21st century air travel

Content-Type: application/octet-stream; name="ATTKHVFA"
Content-Transfer-Encoding: 7bit
Content-Disposition: attachment; filename="ATTKHVFA"
Content-Description: ATTKHVFA
FTBP-Modification-Date: 23 Feb 2001 11:09:00 Z
FTBP-Object-Size: 1390


-- Simple Server

-- Chris Reade, Nov 2000

-- Based on example by  Hermann Oliveira Rodrigues


module Main (main) where

import System

import IO

import Time

import Socket

main :: IO ()

main = do prog <- getProgName

          args <- getArgs

          if (length args /= 1)

              then do putStrLn ("Use: " ++ prog ++ " <port>")

                      exitWith (ExitFailure (-1))

              else return ()

          let port = read (args !! 0) :: Int in

              server (PortNumber (mkPortNumber port))

-- The server function creates a socket to listen on the port and

-- loops to service requests continuously

server :: PortID -> IO ()

server port = do socket <- listenOn port 

                 -- Fique em `loop' atendendo requisicoes.

                 let loop = do (sh, host, portid) <- accept socket

                               procRequest sh

                               loop in


-- The procRequest function deals with an individual request

procRequest :: Handle -> IO ()

procRequest hd = do clock <- getClockTime

                    calendar <- toCalendarTime clock

                    hPutStrLn hd (calendarTimeToString calendar)

                    hFlush hd

                    hClose hd