Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
Synchronet
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
Package registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Main
Synchronet
Commits
b9921c22
Commit
b9921c22
authored
23 years ago
by
rswindell
Browse files
Options
Downloads
Patches
Plain Diff
Socket test module.
parent
f4378b48
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
exec/examples/socktest.js
+45
-0
45 additions, 0 deletions
exec/examples/socktest.js
exec/socktest.src
+63
-0
63 additions, 0 deletions
exec/socktest.src
with
108 additions
and
0 deletions
exec/examples/socktest.js
0 → 100644
+
45
−
0
View file @
b9921c22
load
(
"
sbbsdefs.js
"
);
// CON_RAW_IN
function
test
()
{
var
socket
=
new
Socket
();
socket
.
debug
=
true
;
if
(
!
socket
.
bind
())
{
printf
(
"
!bind error %d
\r\n
"
,
socket
.
last_error
);
exit
();
}
var
addr
=
prompt
(
"
address
"
);
var
port
=
Number
(
prompt
(
"
port
"
));
if
(
!
socket
.
connect
(
addr
,
port
))
{
printf
(
"
!connect error %d
\r\n
"
,
socket
.
last_error
);
exit
();
}
printf
(
"
\r\n
Connected to %s:%d - Ctrl-] to abort
\r\n
"
,
addr
,
port
);
console
.
pause
();
while
(
socket
.
is_connected
&&
client
.
socket
.
is_connected
)
{
if
(
socket
.
data_waiting
)
{
buf
=
socket
.
read
();
client
.
socket
.
write
(
buf
);
continue
;
}
if
((
input
=
console
.
inkey
())
!=
""
)
{
if
(
input
==
"
\
x1d
"
)
/* Ctrl-] */
break
;
socket
.
write
(
input
);
continue
;
}
sleep
(
1
);
}
}
console
.
status
|=
CON_RAW_IN
;
// Enable RAW input mode (pass-through ctrl chars)
test
();
console
.
status
&=
~
CON_RAW_IN
;
// Disable raw input mode
print
(
"
\r\n
End of socktest!
\r\n
"
);
\ No newline at end of file
This diff is collapsed.
Click to expand it.
exec/socktest.src
0 → 100644
+
63
−
0
View file @
b9921c22
!include sbbsdefs.inc
int sock len
str buf
socket_open sock
if_false
print "open failure\r\n"
return
end_if
setstr "cvs.synchro.net"
socket_connect sock str 23
if_false
print "connect failure\r\n"
return
end_if
or _console CON_RAW_IN
loop
inchar
if_true
compare_key ^]
if_equal
break
end_if
copy_char buf
socket_write sock buf
if_false
print "\r\nError writing to socket\r\n"
break
end_if
continue
end_if
socket_check sock
if_false
print "\r\nSocket disconnected\r\n"
break
end_if
socket_nread sock len
if_false
print "\r\nError getting read length\r\n"
break
end_if
compare len 0
if_equal
continue
end_if
# printf "reading %d" len
socket_read sock buf len
if_true
pause_reset
print buf
end_if
end_loop
socket_close sock
xor _console CON_RAW_IN
\ No newline at end of file
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