| 1 |
(* wrapsock.def provides access to low level client socket primitives. |
| 2 |
|
| 3 |
Copyright (C) 2008-2025 Free Software Foundation, Inc. |
| 4 |
Contributed by Gaius Mulley <[email protected]>. |
| 5 |
|
| 6 |
This file is part of GNU Modula-2. |
| 7 |
|
| 8 |
GNU Modula-2 is free software; you can redistribute it and/or modify |
| 9 |
it under the terms of the GNU General Public License as published by |
| 10 |
the Free Software Foundation; either version 3, or (at your option) |
| 11 |
any later version. |
| 12 |
|
| 13 |
GNU Modula-2 is distributed in the hope that it will be useful, but |
| 14 |
WITHOUT ANY WARRANTY; without even the implied warranty of |
| 15 |
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
| 16 |
General Public License for more details. |
| 17 |
|
| 18 |
Under Section 7 of GPL version 3, you are granted additional |
| 19 |
permissions described in the GCC Runtime Library Exception, version |
| 20 |
3.1, as published by the Free Software Foundation. |
| 21 |
|
| 22 |
You should have received a copy of the GNU General Public License and |
| 23 |
a copy of the GCC Runtime Library Exception along with this program; |
| 24 |
see the files COPYING3 and COPYING.RUNTIME respectively. If not, see |
| 25 |
<http://www.gnu.org/licenses/>. *) |
| 26 |
|
| 27 |
DEFINITION MODULE wrapsock ; |
| 28 |
|
| 29 |
(* |
| 30 |
Title : wrapsock |
| 31 |
Author : Gaius Mulley |
| 32 |
System : GNU Modula-2 |
| 33 |
Date : Wed Oct 1 08:40:21 2008 |
| 34 |
Revision : $Version$ |
| 35 |
Description: provides a set of wrappers to some client side |
| 36 |
tcp socket primatives. |
| 37 |
*) |
| 38 |
|
| 39 |
FROM SYSTEM IMPORT ADDRESS ; |
| 40 |
FROM ChanConsts IMPORT OpenResults ; |
| 41 |
|
| 42 |
|
| 43 |
TYPE |
| 44 |
clientInfo = ADDRESS ; |
| 45 |
|
| 46 |
|
| 47 |
(* |
| 48 |
clientOpen - returns an ISO Modula-2 OpenResult. |
| 49 |
It attempts to connect to: hostname:portNo. |
| 50 |
If successful then the data structure, c, |
| 51 |
will have its fields initialized. |
| 52 |
*) |
| 53 |
|
| 54 |
PROCEDURE clientOpen (c: clientInfo; |
| 55 |
hostname: ADDRESS; |
| 56 |
length: CARDINAL; |
| 57 |
portNo: CARDINAL) : OpenResults ; |
| 58 |
|
| 59 |
|
| 60 |
(* |
| 61 |
clientOpenIP - returns an ISO Modula-2 OpenResult. |
| 62 |
It attempts to connect to: ipaddress:portNo. |
| 63 |
If successful then the data structure, c, |
| 64 |
will have its fields initialized. |
| 65 |
*) |
| 66 |
|
| 67 |
PROCEDURE clientOpenIP (c: clientInfo; |
| 68 |
ip: CARDINAL; |
| 69 |
portNo: CARDINAL) : OpenResults ; |
| 70 |
|
| 71 |
|
| 72 |
(* |
| 73 |
getClientPortNo - returns the portNo from structure, c. |
| 74 |
*) |
| 75 |
|
| 76 |
PROCEDURE getClientPortNo (c: clientInfo) : CARDINAL ; |
| 77 |
|
| 78 |
|
| 79 |
(* |
| 80 |
getClientHostname - fills in the hostname of the server |
| 81 |
the to which the client is connecting. |
| 82 |
*) |
| 83 |
|
| 84 |
PROCEDURE getClientHostname (c: clientInfo; |
| 85 |
hostname: ADDRESS; high: CARDINAL) ; |
| 86 |
|
| 87 |
|
| 88 |
(* |
| 89 |
getClientSocketFd - returns the sockFd from structure, c. |
| 90 |
*) |
| 91 |
|
| 92 |
PROCEDURE getClientSocketFd (c: clientInfo) : INTEGER ; |
| 93 |
|
| 94 |
|
| 95 |
(* |
| 96 |
getClientIP - returns the sockFd from structure, s. |
| 97 |
*) |
| 98 |
|
| 99 |
PROCEDURE getClientIP (c: clientInfo) : CARDINAL ; |
| 100 |
|
| 101 |
|
| 102 |
(* |
| 103 |
getPushBackChar - returns TRUE if a pushed back character |
| 104 |
is available. |
| 105 |
*) |
| 106 |
|
| 107 |
PROCEDURE getPushBackChar (c: clientInfo; VAR ch: CHAR) : BOOLEAN ; |
| 108 |
|
| 109 |
|
| 110 |
(* |
| 111 |
setPushBackChar - returns TRUE if it is able to push back a |
| 112 |
character. |
| 113 |
*) |
| 114 |
|
| 115 |
PROCEDURE setPushBackChar (c: clientInfo; ch: CHAR) : BOOLEAN ; |
| 116 |
|
| 117 |
|
| 118 |
(* |
| 119 |
getSizeOfClientInfo - returns the sizeof (opaque data type). |
| 120 |
*) |
| 121 |
|
| 122 |
PROCEDURE getSizeOfClientInfo () : CARDINAL ; |
| 123 |
|
| 124 |
|
| 125 |
END wrapsock. |