Debian Codegraph @

gcc/m2/gm2-libs/sckt.def

raw
1 (* sckt.def provides a minimal interface to tcp sockets.
2
3 Copyright (C) 2003-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 sckt ;
28
29 FROM SYSTEM IMPORT ADDRESS ;
30 EXPORT QUALIFIED tcpServerState,
31 tcpServerEstablish, tcpServerEstablishPort,
32 tcpServerAccept, getLocalIP,
33 tcpServerPortNo, tcpServerIP, tcpServerSocketFd,
34 tcpServerClientIP, tcpServerClientPortNo,
35 tcpClientState,
36 tcpClientSocket, tcpClientSocketIP, tcpClientConnect,
37 tcpClientPortNo, tcpClientIP, tcpClientSocketFd ;
38
39 TYPE
40 tcpServerState = ADDRESS ;
41 tcpClientState = ADDRESS ;
42
43
44 (*
45 tcpServerEstablish - returns a tcpState containing the relevant
46 information about a socket declared to receive
47 tcp connections.
48 *)
49
50 PROCEDURE tcpServerEstablish () : tcpServerState ;
51
52
53 (*
54 tcpServerEstablishPort - returns a tcpState containing the relevant
55 information about a socket declared to receive
56 tcp connections. This method attempts to use
57 the port specified by the parameter.
58 *)
59
60 PROCEDURE tcpServerEstablishPort (port: CARDINAL) : tcpServerState ;
61
62
63 (*
64 tcpServerAccept - returns a file descriptor once a client has connected and
65 been accepted.
66 *)
67
68 PROCEDURE tcpServerAccept (s: tcpServerState) : INTEGER ;
69
70
71 (*
72 tcpServerPortNo - returns the portNo from structure, s.
73 *)
74
75 PROCEDURE tcpServerPortNo (s: tcpServerState) : CARDINAL ;
76
77
78 (*
79 tcpSocketFd - returns the sockFd from structure, s.
80 *)
81
82 PROCEDURE tcpServerSocketFd (s: tcpServerState) : INTEGER ;
83
84
85 (*
86 getLocalIP - returns the IP address of this machine.
87 *)
88
89 PROCEDURE getLocalIP (s: tcpServerState) : CARDINAL ;
90
91
92 (*
93 tcpServerIP - returns the IP address from structure, s.
94 *)
95
96 PROCEDURE tcpServerIP (s: tcpServerState) : CARDINAL ;
97
98
99 (*
100 tcpServerClientIP - returns the IP address of the client who
101 has connected to server, s.
102 *)
103
104 PROCEDURE tcpServerClientIP (s: tcpServerState) : CARDINAL ;
105
106
107 (*
108 tcpServerClientPortNo - returns the port number of the client who
109 has connected to server, s.
110 *)
111
112 PROCEDURE tcpServerClientPortNo (s: tcpServerState) : CARDINAL ;
113
114
115 (*
116 tcpClientSocket - returns a file descriptor (socket) which has
117 connected to, serverName:portNo.
118 *)
119
120 PROCEDURE tcpClientSocket (serverName: ADDRESS; portNo: CARDINAL) : tcpClientState ;
121
122
123 (*
124 tcpClientSocketIP - returns a file descriptor (socket) which has
125 connected to, ip:portNo.
126 *)
127
128 PROCEDURE tcpClientSocketIP (ip: CARDINAL; portNo: CARDINAL) : tcpClientState ;
129
130
131 (*
132 tcpClientConnect - returns the file descriptor associated with, s,
133 once a connect has been performed.
134 *)
135
136 PROCEDURE tcpClientConnect (s: tcpClientState) : INTEGER ;
137
138
139 (*
140 tcpClientPortNo - returns the portNo from structure, s.
141 *)
142
143 PROCEDURE tcpClientPortNo (s: tcpClientState) : INTEGER ;
144
145
146 (*
147 tcpClientSocketFd - returns the sockFd from structure, s.
148 *)
149
150 PROCEDURE tcpClientSocketFd (s: tcpClientState) : INTEGER ;
151
152
153 (*
154 tcpClientIP - returns the IP address from structure, s.
155 *)
156
157 PROCEDURE tcpClientIP (s: tcpClientState) : CARDINAL ;
158
159
160 END sckt.