-
Notifications
You must be signed in to change notification settings - Fork 29
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Peers now transmit their role before sending file #13
base: master
Are you sure you want to change the base?
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -18,6 +18,16 @@ static internal void Run(UdtSocket conn) | |
using (var writer = new BinaryWriter(netStream)) | ||
using (var reader = new BinaryReader(netStream)) | ||
{ | ||
// transmit your role and check if connected peer has the correct role | ||
writer.Write(Program.ReceiverRole); | ||
string role = reader.ReadString(); | ||
|
||
if (role == Program.ReceiverRole) | ||
{ | ||
Console.Error.WriteLine("Peers can't have the same role."); | ||
return; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. if you exit the function like this, this won't translate into a non-zero exitcode for the program There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. What do you suggest instead? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. call directly Environment.Exit? I know it doesn't seem very clean, but it would be more correct. |
||
} | ||
|
||
string fileName = reader.ReadString(); | ||
long size = reader.ReadInt64(); | ||
|
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
let's rather use an enum? and then use .ToString()