# Crystal Space Network Driver Interface description.

#### Created by Serguei 'Snaar' Narojnyi. Last updated on 03 April 1999. If you have questions/suggestions mail me at snaar@idirect.ca or wormzstudios@iname.com.

### Table of contents:

1. Overview
   1. Welcome to Crystal Space Network Driver Interface
   2. Building applications
2. Reference
   1. Functions
   2. Structures and Enumerations

## 1. Overview

> ### 1. Welcome to Crystal Space Network Driver Interface

> ### 2. Building applications

## 2. Reference

> ### 1. Functions

> > #### Open
> > Close
> > Connect
> > Disconnect
> > Send
> > Receive
> > SetListenState
> > Accept
> > Spawn
> > Kill
> > KillAll
> > GetDriverCaps
> > GetLastError

> ### Open

> This function opens network driver. Automatically called by system on startup.

> HRESULT Open(void);

> ### Remarks

> This function should not normally be called by user.

> ### Return Values

> CS_NET_SUCCESS (S_OK) is returned on success otherwise CS_NET_FAIL (S_FALSE) is returned.

> ### Close

> This function closes network driver. Automatically called by system on shutdown.

> HRESULT Close(void);

> ### Remarks

> This function should not normally be called by user.

> ### Return Values

> CS_NET_SUCCESS (S_OK) is returned on success otherwise CS_NET_FAIL (S_FALSE) is returned.

> ### Connect

> This function connects socket to remote computer.

> HRESULT Connect(DWORD dwID, CS_NET_ADDRESS *lpNetAddress);

> ### Parameters

> dwID

> [in] socket ID

> lpNetAddress

> [in] remote address to connect to

> ### Return Values

> CS_NET_SUCCESS (S_OK) is returned on success otherwise CS_NET_FAIL (S_FALSE) is returned.

> ### Disconnect

> This function disconnects socket.

> HRESULT Disconnect(DWORD dwID);

> ### Parameters

> dwID

> [in] socket ID

> ### Return Values

> CS_NET_SUCCESS (S_OK) is returned on success otherwise CS_NET_FAIL (S_FALSE) is returned.

> ### Send

> This function sends data to socket.

> HRESULT Send(DWORD dwID, DWORD dwBytesToSend, char *lpDataBuffer);

> ### Parameters

> dwID

> [in] socket ID

> dwBytesToSend

> [in] number of bytes to send

> lpDataBuffer

> [in] pointer to data buffer

> ### Return Values

> CS_NET_SUCCESS (S_OK) is returned on success otherwise CS_NET_FAIL (S_FALSE) is returned.

> ### Receive

> This function receives data from socket.

> HRESULT Receive(DWORD dwID, DWORD *lpdwBytesToReceive /* in/out */, char *lpDataBuffer);

> ### Parameters

> dwID

> [in] socket ID

> lpdwBytesToReceive

> [out] pointer to number of bytes received

> lpDataBuffer

> [out] pointer to data buffer

> ### Return Values

> CS_NET_SUCCESS (S_OK) is returned on success otherwise CS_NET_FAIL (S_FALSE) is returned.

> ### SetListenState

> This function sets socket to listen state.

> HRESULT SetListenState(DWORD dwID, CS_NET_LISTENPARAMS *lpCSListenParams);

> ### Parameters

> dwID

> [in] socket ID

> lpCSListenParams

> [in] pointer to listen parameters structure

> ### Return Values

> CS_NET_SUCCESS (S_OK) is returned on success otherwise CS_NET_FAIL (S_FALSE) is returned.

> ### Accept

> This function accepts incoming connections on socket.

> HRESULT Accept(DWORD dwLID/*listening socket*/, DWORD *lpdwID/*server socket*/, CS_NET_ADDRESS *lpCSNetAddress/*out*/);

> ### Parameters

> dwLID

> [in] listening socket ID

> lpdwID

> [out] pointer to server socket ID

> lpCSNetAddress

> [out] pointer to structure filled with incoming connection address

> ### Return Values

> CS_NET_SUCCESS (S_OK) is returned on success otherwise CS_NET_FAIL (S_FALSE) is returned.

> ### Spawn

> This function creates new socket.

> HRESULT Spawn(DWORD *lpdwID /*out*/, DWORD dwType);

> ### Parameters

> lpdwID

> [out] pointer to newly created socket ID

> dwType

> [in] type of socket to create

> ### Return Values

> CS_NET_SUCCESS (S_OK) is returned on success otherwise CS_NET_FAIL (S_FALSE) is returned.

> ### Kill

> This function kills socket.

> HRESULT Kill(DWORD dwID);

> ### Parameters

> dwID

> [in] socket ID to kill

> ### Return Values

> CS_NET_SUCCESS (S_OK) is returned on success otherwise CS_NET_FAIL (S_FALSE) is returned.

> ### KillAll

> This function kills all sockets.

> HRESULT KillAll();

> ### Return Values

> CS_NET_SUCCESS (S_OK) is returned on success otherwise CS_NET_FAIL (S_FALSE) is returned.

> ### GetDriverCaps

> This function gets driver capabilities.

> HRESULT GetDriverCaps(CS_NET_DRIVERCAPS *lpCSNetDriverCaps);

> ### Parameters

> lpCSNetDriverCaps

> [out] pointer to driver caps structure

> ### Return Values

> CS_NET_SUCCESS (S_OK) is returned on success otherwise CS_NET_FAIL (S_FALSE) is returned.

> ### GetLastError

> This function returns last error.

> HRESULT GetLastError();

> ### Return Values

> CS_NET_SUCCESS (S_OK) is returned on success otherwise CS_NET_FAIL (S_FALSE) is returned.

> ### 2. Structures and Enumerations