Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
C
cs425_mp1
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
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
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
yf3
cs425_mp1
Commits
258ebdf4
Commit
258ebdf4
authored
6 years ago
by
yshen47
Browse files
Options
Downloads
Patches
Plain Diff
set to be debug mode
parent
26c24cda
No related branches found
No related tags found
No related merge requests found
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
cmd/chat-server/main.go
+1
-1
1 addition, 1 deletion
cmd/chat-server/main.go
cmd/tcp-client/main.go
+0
-26
0 additions, 26 deletions
cmd/tcp-client/main.go
cmd/tcp-server/main.go
+0
-46
0 additions, 46 deletions
cmd/tcp-server/main.go
server/server.go
+0
-1
0 additions, 1 deletion
server/server.go
with
1 addition
and
74 deletions
cmd/chat-server/main.go
+
1
−
1
View file @
258ebdf4
...
@@ -10,7 +10,7 @@ import (
...
@@ -10,7 +10,7 @@ import (
"strconv"
"strconv"
)
)
var
DEBUG
=
fals
e
var
DEBUG
=
tru
e
func
main
()
{
func
main
()
{
...
...
This diff is collapsed.
Click to expand it.
cmd/tcp-client/main.go
deleted
100644 → 0
+
0
−
26
View file @
26c24cda
package
main
import
(
"bufio"
"fmt"
"net"
"time"
)
func
listen
(
conn
net
.
Conn
)
{
for
{
// read in input from stdin
// listen for reply
message
,
_
:=
bufio
.
NewReader
(
conn
)
.
ReadString
(
'\n'
)
fmt
.
Print
(
"Message from server: "
+
message
)
}
}
func
main
()
{
// connect to this socket
conn
,
_
:=
net
.
Dial
(
"tcp"
,
"127.0.0.1:8081"
)
go
listen
(
conn
)
}
This diff is collapsed.
Click to expand it.
cmd/tcp-server/main.go
deleted
100644 → 0
+
0
−
46
View file @
26c24cda
package
main
import
(
"bufio"
"fmt"
"net"
"os"
"strings"
)
func
send
(
conn
net
.
Conn
)
{
for
{
reader
:=
bufio
.
NewReader
(
os
.
Stdin
)
fmt
.
Print
(
"Text to send: "
)
text
,
_
:=
reader
.
ReadString
(
'\n'
)
// send to socket
fmt
.
Fprintf
(
conn
,
text
+
"
\n
"
)
}
}
func
main
()
{
fmt
.
Println
(
"Launching server..."
)
// listen on all interfaces
ln
,
_
:=
net
.
Listen
(
"tcp"
,
":8081"
)
// accept connection on port
conn
,
_
:=
ln
.
Accept
()
go
send
(
conn
)
fmt
.
Println
(
conn
.
LocalAddr
())
// run loop forever (or until ctrl-c)
for
{
// will listen for message to process ending in newline (\n)
message
,
_
:=
bufio
.
NewReader
(
conn
)
.
ReadString
(
'\n'
)
// output message received
fmt
.
Print
(
"Message Received:"
,
string
(
message
),
"
\n
"
)
// sample process for string received
newmessage
:=
strings
.
ToUpper
(
message
)
// send new string back to client
conn
.
Write
([]
byte
(
newmessage
+
"
\n
"
))
}
}
\ No newline at end of file
This diff is collapsed.
Click to expand it.
server/server.go
+
0
−
1
View file @
258ebdf4
...
@@ -27,7 +27,6 @@ type Server struct {
...
@@ -27,7 +27,6 @@ type Server struct {
VectorTimestampMutex
sync
.
Mutex
VectorTimestampMutex
sync
.
Mutex
messageQueue
[]
Message
messageQueue
[]
Message
messageQueueMutex
sync
.
Mutex
messageQueueMutex
sync
.
Mutex
}
}
func
(
s
*
Server
)
Constructor
(
name
string
,
peopleNum
int
,
portNum
int
,
myAddr
string
,
globalServerAddrs
[]
string
)
{
func
(
s
*
Server
)
Constructor
(
name
string
,
peopleNum
int
,
portNum
int
,
myAddr
string
,
globalServerAddrs
[]
string
)
{
...
...
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