source: trunk/gsdl/src/w32server/netio.h@ 1203

Last change on this file since 1203 was 1203, checked in by sjboddie, 24 years ago

Made a few minor changes to get the local library compiling under VC++ 6.0
using the built-in STL (i.e. without the GSDL_USE_IOS_H pre-processor
definition set).

  • Property svn:executable set to *
  • Property svn:keywords set to Author Date Id Revision
File size: 4.6 KB
Line 
1/*
2Copyright (C) 1996
3
4This program is free software; you can redistribute it and/or modify
5it under the terms of the GNU General Public License as published by
6the Free Software Foundation; either version 2 of the License, or
7(at your option) any later version.
8
9This program is distributed in the hope that it will be useful,
10but WITHOUT ANY WARRANTY; without even the implied warranty of
11MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12GNU General Public License for more details.
13
14You should have received a copy of the GNU General Public License
15along with this program; if not, write to the Free Software
16Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
17
18The author can be contacted via Email at [email protected]
19*/
20
21/*
22Module Name: Net IO
23Purpose: High level Socket IO and Misc socket routines
24Public Functions:
25 InitNetIO
26 CleanUpNetIO
27
28 GetLocalIP
29 GetLocalName
30
31 CreateListeningSocket
32 AnswerListeningSocket
33 DestroyListeningSocket
34
35 CloseSocket
36
37 GetData
38 GetLine
39
40 SendData
41 SendFile
42*/
43
44//Public definitions
45//Max line size for GetLine
46#define NETIO_MAX_LINE 300
47
48//Public Functions
49
50/*
51Function Name: Init Net IO
52Purpose: Initializes the module so calls can be made querying network
53 information for the local macnine.
54Notes: MUST be called before GetLocalIP and GetLocalName
55*/
56
57// returns 0 on success,
58// WSASYSNOTREADY, WSAVERNOTSUPPORTED, or WSAEINVAL on failure
59int InitNetIO();
60
61/*
62Function Name: Cleanup Net IO
63Purpose: Cleans up the module and unloads Winsock
64*/
65void CleanUpNetIO();
66
67/*
68Function Name: Reset Net IO
69Purpose: Resets internal data in NetIO to reflect registry changes, etc.
70*/
71void ResetNetIO();
72
73/*
74Function Name: Get Local IP
75Purpose: Gets the local IP number
76Returns: The local IP number as an double word (4 bytes)
77*/
78DWORD GetLocalIP();
79
80/*
81Function Name: Get Local Name
82Purpose: Gets the local Domain name, or if there is none, then the server
83address in dotted format.
84Returns: A string containing the local address
85*/
86char *GetLocalName(HINSTANCE hInstance);
87
88// returns 0 on success, and a WSA error message on failure.
89// possible error messages include:
90// WSANOTINITIALISED, WSAENETDOWN, WSAEAFNOSUPPORT, WSAEINPROGRESS, WSAEMFILE,
91// WSAENOBUFS, WSAEPROTONOSUPPORT, WSAEPROTOTYPE, WSAESOCKTNOSUPPORT,
92// WSAEADDRINUSE, WSAEINVAL, WSAEISCONN, WSAENOTSOCK, WSAEOPNOTSUPP
93int CreateListeningSocket(int &PortNum, HWND MsgWindow, WORD SocketMsg, SOCKET &ServerSocket);
94
95int AnswerListeningSocket(SOCKET ServerSocket, SOCKET &ClientSocket, SOCKADDR_IN &ClientSockAddr, int AddrLen);
96
97void DestroyListeningSocket(SOCKET &ServerSocket, HWND MsgWindow);
98
99void CloseSocket(SOCKET &TargetSocket);
100
101/*
102Function Name: Get Data
103Purpose: Gets data from a socket with muli-threaded debugging
104Parameters:
105 ClientSocket - The socket to get data from
106 IOBuffer - A pointer to a chunk of memory to put data in
107 IOBufferSize - Size of the buffer
108 ThreadNum - Number of the thread that called this functions used for debugging
109
110Returns: -1 on error, else the number of bytes received
111
112Notes:
113Removed socket error checking because I was unable to isolate what
114errors I was getting when getting a "rude" disconnect
115*/
116int GetData(SOCKET ClientSocket, BYTE *IOBuffer, int IOBufferSize, int ThreadNum);
117
118/*
119Function Name: Get Line
120Purpose: Gets a line of text (ended by a LF (10)) from a socket with buffered
121 input. If the buffer is empty this function fills the buffer, else it
122 just changes an index. Also has the ability to do multi-threaded debuging
123Parameters:
124 OutStr - Varible were output is put (a length of NETIO_MAX_LINE is assumed)
125 ClientSocket - The socket to get data from
126 IOBuffer - A pointer to a chunk of memory to put data in
127 IOBufferSize - Size of the buffer
128 BufferIndex - A zero based index of what charactor in the buffer we're at
129 DataInBuffer - Amount of data in the buffer
130 ThreadNum - Number of the thread that called this functions used for debugging
131
132Returns: -1 on disconnect or error (abort connection), 0 on success
133*/
134int GetLine(char *OutStr, SOCKET ClientSocket, BYTE *IOBuffer, int IOBufferSize, int &BufferIndex, int &DataInBuffer, int ThreadNum);
135
136/*
137Function Name: Send Data
138Purpose: Sends data to a socket with muli-thread debugging
139Parameters:
140 ClientSocket - The socket to get data from
141 SendBuffer - A pointer to a chunk of memory to put data in
142 NumToSend - Number of bytes to send from buffer
143 ThreadNum - Number of the thread that called this functions used for debugging
144
145Returns: -1 on error, 0 on success
146
147Notes:
148Removed socket error checking because I was unable to isolate what
149errors I was getting when getting a "rude" disconnect
150*/
151int SendData(SOCKET ClientSocket, BYTE *SendBuffer, int NumToSend, int ThreadNum);
Note: See TracBrowser for help on using the repository browser.