Skip to content
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

add TCP and UDP server samples #243

Merged
merged 2 commits into from
Apr 9, 2020
Merged

Conversation

matsievskiysv
Copy link

Add TCP and UDP server samples.
See #235 for details.

Copy link
Collaborator

@psychon psychon left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the examples and sorry for the many comments

local Gio = lgi.Gio

local app = Gio.Application{application_id = 'org.test.tcptest',
flags = Gio.ApplicationFlags.NON_UNIQUE}
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why is this a Gio.Application? I have to admit, I do not really know what this is doing, but I would just remove the app.
(Especially with the NON_UNIQUE argument... what does Gio.Application do?)

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Honestly everything should be using Gio.Application, manually dealing with the mainloop isn't helpful.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Well, what does GApplication do that GLib.MainLoop.new():run() does not do? I really have no idea.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Most examples use Gio.Application. Probably because syntax is the same as for Gtk.Application.

Copy link
Contributor

@TingPing TingPing Apr 9, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In the context of a demo, nothing. In real world applications, single instance support, daemonization, argument parsing, gresource loading, global menus, exporting the freedesktop application dbus interface, its just the API applications should use.

@matsievskiysv
Copy link
Author

Copied assertion from samples/giostream.lua, so it should be double checked. Applied other suggestions.

@matsievskiysv
Copy link
Author

Tried to test error handling by inserting packet delays and errors via tc, but it didn't work. I think, these errors were caught on kernel level. How do I get Gio to fail?

@psychon
Copy link
Collaborator

psychon commented Apr 9, 2020

I don't know why, but the TCP echo server truncates(?) long messages. I used copy&paste to generate lots of "o"s, but the server answered with less "o"s.

I tried to get some kind of error, but I also failed. I guess just guessing that it works should be okay then.

@TingPing You already checked an earlier version of this. Any more comments or should I just merge this?

@TingPing
Copy link
Contributor

TingPing commented Apr 9, 2020

Seems good.

@matsievskiysv
Copy link
Author

I don't know why, but the TCP echo server truncates(?) long messages. I used copy&paste to generate lots of "o"s, but the server answered with less "o"s.

This may be a netcat issue. I used this sample text. When I copy/pasted it into ncat, it got truncated on the phrase From whispers in the wind he could foretell the next day’s weather. Bec, but when I piped xclip contents to the ncat, server received the whole text.

@psychon psychon merged commit 9541863 into lgi-devs:master Apr 9, 2020
@psychon
Copy link
Collaborator

psychon commented Apr 9, 2020

Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants