Commit ba6cc328 authored by sof's avatar sof
Browse files

[project @ 1999-05-05 10:34:53 by sof]

stubs for starting & stopping Winsock
parent e548e8aa
......@@ -21,4 +21,8 @@ LIBRARY=libHSmisc_cbits.a
LIBOBJS=$(C_OBJS)
INSTALL_LIBS += $(LIBRARY)
DLL_NAME = HSmisc_cbits.dll
SRC_BLD_DLL_OPTS += --export-all --output-def=HSmisc_cbits.def
SRC_BLD_DLL_OPTS += -lwinmm -lwsock32 -lHSrts_imp -lHS_cbits_imp -lgmp -L. -L../../../rts/gmp -L../../../rts -L../../std/cbits
include $(TOP)/mk/target.mk
#ifndef GHC_SOCKETS_H
#define GHC_SOCKETS_H
#ifdef HAVE_WINSOCK_H
#include <winsock.h>
#else
#include <ctype.h>
#include <netdb.h>
#include <netinet/in.h>
......@@ -39,7 +43,7 @@
#include <sys/uio.h>
/* ToDo: featurise this */
#ifndef cygwin32_TARGET_OS
#if !defined(cygwin32_TARGET_OS) && !defined(mingw32_TARGET_OS)
#include <sys/un.h>
#endif
......@@ -47,6 +51,8 @@
# include <unistd.h>
#endif
#endif /* !HAVE_WINSOCK_H */
/* acceptSocket.lc */
StgInt acceptSocket (StgInt, StgAddr, StgAddr);
......@@ -87,5 +93,10 @@ StgInt setSocketOption__ (StgInt, StgInt, StgInt);
/* writeDescriptor.lc */
StgInt writeDescriptor (StgInt, StgAddr, StgInt);
/* initWinSock.c */
#ifdef _WIN32
StgInt initWinSock();
void shutdownWinSock();
#endif
#endif /* !GHC_SOCKETS_H */
#define NON_POSIX_SOURCE
#include "Rts.h"
#include "ghcSockets.h"
#include "stgio.h"
#ifdef _WIN32
/* Initialising WinSock... */
StgInt
initWinSock ()
{
WORD wVersionRequested;
WSADATA wsaData;
int err;
wVersionRequested = MAKEWORD( 1, 1 );
err = WSAStartup ( wVersionRequested, &wsaData );
if ( err != 0 ) {
return err;
}
if ( LOBYTE( wsaData.wVersion ) != 1 ||
HIBYTE( wsaData.wVersion ) != 1 ) {
WSACleanup();
return (-1);
}
return 0;
}
void
shutdownWinSock()
{
WSACleanup();
}
#endif
......@@ -94,7 +94,7 @@ char *realloc ();
This is used in most programs--a few other programs avoid this
by defining INHIBIT_STRING_HEADER. */
#ifndef INHIBIT_STRING_HEADER
#if defined (HAVE_STRING_H) || defined (STDC_HEADERS) || defined (_LIBC)
#if defined (HAVE_STRING_H) || defined (STDC_HEADERS) || defined (_LIBC) || defined(_WIN32)
#include <string.h>
#ifndef bcmp
#define bcmp(s1, s2, n) memcmp ((s1), (s2), (n))
......
......@@ -19,7 +19,11 @@ StgInt opt;
{
int level,optval, sz_optval,rc;
if ( opt == TCP_MAXSEG || opt == TCP_NODELAY ) {
if (
#ifndef _WIN32
opt == TCP_MAXSEG ||
#endif
opt == TCP_NODELAY ) {
level = IPPROTO_TCP;
} else {
level = SOL_SOCKET;
......@@ -45,7 +49,11 @@ StgInt val;
{
int level, optval,rc;
if ( opt == TCP_MAXSEG || opt == TCP_NODELAY ) {
if (
#ifndef _WIN32
opt == TCP_MAXSEG ||
#endif
opt == TCP_NODELAY ) {
level = IPPROTO_TCP;
} else {
level = SOL_SOCKET;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment