gtcpconnection.go RawHistoryFolder
1// Package gio was automatically generated by github.com/bnema/puregotk DO NOT EDIT
2package gio
3
4import (
5 "structs"
6 "unsafe"
7
8 "github.com/ebitengine/purego"
9
10 "github.com/bnema/puregotk/pkg/core"
11 "github.com/bnema/puregotk/v4/gobject"
12 "github.com/bnema/puregotk/v4/gobject/types"
13)
14
15type TcpConnectionClass struct {
16 _ structs.HostLayout
17
18 ParentClass SocketConnectionClass
19}
20
21func (x *TcpConnectionClass) GoPointer() uintptr {
22 return uintptr(unsafe.Pointer(x))
23}
24
25type TcpConnectionPrivate struct {
26 _ structs.HostLayout
27}
28
29func (x *TcpConnectionPrivate) GoPointer() uintptr {
30 return uintptr(unsafe.Pointer(x))
31}
32
33// This is the subclass of [class@Gio.SocketConnection] that is created
34// for TCP/IP sockets.
35type TcpConnection struct {
36 SocketConnection
37}
38
39var xTcpConnectionGLibType func() types.GType
40
41func TcpConnectionGLibType() types.GType {
42 return xTcpConnectionGLibType()
43}
44
45func TcpConnectionNewFromInternalPtr(ptr uintptr) *TcpConnection {
46 cls := &TcpConnection{}
47 cls.Ptr = ptr
48 return cls
49}
50
51var xTcpConnectionGetGracefulDisconnect func(uintptr) bool
52
53// Checks if graceful disconnects are used. See
54// g_tcp_connection_set_graceful_disconnect().
55func (x *TcpConnection) GetGracefulDisconnect() bool {
56
57 cret := xTcpConnectionGetGracefulDisconnect(x.GoPointer())
58 return cret
59}
60
61var xTcpConnectionSetGracefulDisconnect func(uintptr, bool)
62
63// This enables graceful disconnects on close. A graceful disconnect
64// means that we signal the receiving end that the connection is terminated
65// and wait for it to close the connection before closing the connection.
66//
67// A graceful disconnect means that we can be sure that we successfully sent
68// all the outstanding data to the other end, or get an error reported.
69// However, it also means we have to wait for all the data to reach the
70// other side and for it to acknowledge this by closing the socket, which may
71// take a while. For this reason it is disabled by default.
72func (x *TcpConnection) SetGracefulDisconnect(GracefulDisconnectVar bool) {
73
74 xTcpConnectionSetGracefulDisconnect(x.GoPointer(), GracefulDisconnectVar)
75
76}
77
78func (c *TcpConnection) GoPointer() uintptr {
79 if c == nil {
80 return 0
81 }
82 return c.Ptr
83}
84
85func (c *TcpConnection) SetGoPointer(ptr uintptr) {
86 c.Ptr = ptr
87}
88
89// SetPropertyGracefulDisconnect sets the "graceful-disconnect" property.
90// Whether [method@Gio.IOStream.close] does a graceful disconnect.
91func (x *TcpConnection) SetPropertyGracefulDisconnect(value bool) {
92 var v gobject.Value
93 v.Init(gobject.TypeBooleanVal)
94 v.SetBoolean(value)
95 x.SetProperty("graceful-disconnect", &v)
96}
97
98// GetPropertyGracefulDisconnect gets the "graceful-disconnect" property.
99// Whether [method@Gio.IOStream.close] does a graceful disconnect.
100func (x *TcpConnection) GetPropertyGracefulDisconnect() bool {
101 var v gobject.Value
102 x.GetProperty("graceful-disconnect", &v)
103 return v.GetBoolean()
104}
105
106func init() {
107 core.SetPackageName("GIO", "gio-2.0")
108 core.SetSharedLibraries("GIO", []string{"libgio-2.0.so.0"})
109 var libs []uintptr
110 for _, libPath := range core.GetPaths("GIO") {
111 lib, err := purego.Dlopen(libPath, purego.RTLD_NOW|purego.RTLD_GLOBAL)
112 if err != nil {
113 panic(err)
114 }
115 libs = append(libs, lib)
116 }
117
118 core.PuregoSafeRegister(&xTcpConnectionGLibType, libs, "g_tcp_connection_get_type")
119
120 core.PuregoSafeRegister(&xTcpConnectionGetGracefulDisconnect, libs, "g_tcp_connection_get_graceful_disconnect")
121 core.PuregoSafeRegister(&xTcpConnectionSetGracefulDisconnect, libs, "g_tcp_connection_set_graceful_disconnect")
122
123}