Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
pike
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container registry
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
pikelang
pike
Commits
5fedf1b7
Commit
5fedf1b7
authored
26 years ago
by
Fredrik Hübinette (Hubbe)
Browse files
Options
Downloads
Patches
Plain Diff
implemented (working) close() function
Rev: lib/modules/Protocols.pmod/TELNET.pmod:1.7
parent
579780cb
No related branches found
No related tags found
No related merge requests found
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
lib/modules/Protocols.pmod/TELNET.pmod
+33
-12
33 additions, 12 deletions
lib/modules/Protocols.pmod/TELNET.pmod
with
33 additions
and
12 deletions
lib/modules/Protocols.pmod/TELNET.pmod
+
33
−
12
View file @
5fedf1b7
//
// $Id: TELNET.pmod,v 1.
6
1999/0
4/30 06:56:24
hubbe Exp $
// $Id: TELNET.pmod,v 1.
7
1999/0
6/05 04:20:03
hubbe Exp $
//
// The TELNET protocol as described by RFC 764 and others.
//
...
...
@@ -273,6 +273,10 @@ class protocol
//. Data queued to be sent.
static string to_send = "";
//. + done
//. Indicates that connection should be closed
static int done;
//. + nonblocking_write
//. Tells if we have set the nonblocking write callback or not.
static int nonblocking_write;
...
...
@@ -281,7 +285,7 @@ class protocol
//. Turns on the write callback if apropriate.
static void enable_write()
{
if (!nonblocking_write && (write_cb || sizeof(to_send))) {
if (!nonblocking_write && (write_cb || sizeof(to_send)
|| done
)) {
fd->set_nonblocking(got_data, send_data, close_cb, got_oob);
nonblocking_write = 1;
}
...
...
@@ -291,7 +295,7 @@ class protocol
//. Turns off the write callback if apropriate.
static void disable_write()
{
if (!write_cb && !sizeof(to_send) && nonblocking_write) {
if (!write_cb && !sizeof(to_send) &&
!done &&
nonblocking_write) {
fd->set_nonblocking(got_data, 0, close_cb, got_oob);
nonblocking_write = 0;
}
...
...
@@ -307,7 +311,7 @@ class protocol
enable_write();
}
//.
+
write_raw
//.
-
write_raw
//. Queues raw data to be sent to the other end of the connection.
//. > s - String with raw telnet data to send.
void write_raw(string s)
...
...
@@ -316,6 +320,14 @@ class protocol
enable_write();
}
//. - close
//. Closes the connetion neatly
void close()
{
done=1;
enable_write();
}
//. - send_data
//. Callback called when it is clear to send data over the connection.
//. This function does the actual sending.
...
...
@@ -323,14 +335,16 @@ class protocol
{
if (!sizeof(to_send)) {
if (write_cb) {
to_send = write_cb(id);
if(!(to_send = write_cb(id)))
{
done=1;
to_send="";
}
}
if (!to_send) {
// Support for delayed close.
fd->close();
fd = 0;
} else if (sizeof(to_send)) {
}
if (sizeof(to_send))
{
if (to_send[0] == 242) {
// DataMark needs extra quoting... Stupid.
to_send = C2(IAC,NOP) + to_send;
...
...
@@ -339,6 +353,11 @@ class protocol
int n = fd->write(to_send);
to_send = to_send[n..];
} else if(done) {
fd->close();
fd=0;
nonblocking_write=0;
return;
}
disable_write();
}
...
...
@@ -989,9 +1008,11 @@ class Readline
}
}
void
destroy
()
void
close
()
{
if(readline) destruct(readline);
readline->set_blocking();
readline=0;
::close();
}
}
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment