Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
C
Cs283
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
Joey Le
Cs283
Commits
4ec5ab7a
Commit
4ec5ab7a
authored
2 months ago
by
Joey Le
Browse files
Options
Downloads
Patches
Plain Diff
Impmeneted boot server hopefully
parent
ecb0d781
Branches
Branches containing commit
No related tags found
No related merge requests found
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
Assignment-06/starter/dshlib.c
+6
-0
6 additions, 0 deletions
Assignment-06/starter/dshlib.c
Assignment-06/starter/rsh_server.c
+27
-7
27 additions, 7 deletions
Assignment-06/starter/rsh_server.c
with
33 additions
and
7 deletions
Assignment-06/starter/dshlib.c
+
6
−
0
View file @
4ec5ab7a
...
...
@@ -206,6 +206,12 @@ int execute_pipeline(command_list_t *clist) {
return
OK
;
}
static
void
start_server
()
{
int
listen_socket
;
int
ret
;
}
/****
**** FOR REMOTE SHELL USE YOUR SOLUTION FROM SHELL PART 3 HERE
**** THE MAIN FUNCTION CALLS THIS ONE AS ITS ENTRY POINT TO
...
...
This diff is collapsed.
Click to expand it.
Assignment-06/starter/rsh_server.c
+
27
−
7
View file @
4ec5ab7a
...
...
@@ -50,11 +50,6 @@ int start_server(char *ifaces, int port, int is_threaded){
int
svr_socket
;
int
rc
;
//
//TODO: If you are implementing the extra credit, please add logic
// to keep track of is_threaded to handle this feature
//
svr_socket
=
boot_server
(
ifaces
,
port
);
if
(
svr_socket
<
0
){
int
err_code
=
svr_socket
;
//server socket will carry error code
...
...
@@ -117,11 +112,35 @@ int stop_server(int svr_socket){
int
boot_server
(
char
*
ifaces
,
int
port
){
int
svr_socket
;
int
ret
;
struct
sockaddr_in
addr
;
// TODO set up the socket - this is very similar to the demo code
svr_socket
=
socket
(
AF_INET
,
SOCK_STREAM
,
0
);
if
(
svr_socket
==
-
1
)
{
perror
(
"socket"
);
return
ERR_RDSH_SERVER
;
}
int
enable
=
1
;
if
(
setsockopt
(
svr_socket
,
SOL_SOCKET
,
SO_REUSEADDR
,
&
enable
,
sizeof
(
int
))
<
0
)
{
perror
(
"setsockopt"
);
close
(
svr_socket
);
return
ERR_RDSH_SERVER
;
}
addr
.
sin_family
=
AF_INET
;
addr
.
sin_addr
.
s_addr
=
inet_addr
(
ifaces
);
addr
.
sin_port
=
htons
(
port
);
ret
=
bind
(
svr_socket
,
(
const
struct
sockaddr
*
)
&
addr
,
sizeof
(
struct
sockaddr_in
));
if
(
ret
==
-
1
)
{
perror
(
"bind"
);
close
(
svr_socket
);
return
ERR_RDSH_SERVER
;
}
/*
* Prepare for accepting connections. The backlog size is set
* to 20. So while one request is being processed other requests
...
...
@@ -133,6 +152,7 @@ int boot_server(char *ifaces, int port){
return
ERR_RDSH_COMMUNICATION
;
}
printf
(
"SERVER BOOTED on %s:%d
\n
"
,
ifaces
,
port
);
return
svr_socket
;
}
...
...
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