v0.2.2 9100209

gsocket.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/glib"
12	"github.com/bnema/puregotk/v4/gobject"
13	"github.com/bnema/puregotk/v4/gobject/types"
14)
15
16type SocketClass struct {
17	_ structs.HostLayout
18
19	ParentClass gobject.ObjectClass
20
21	xGReserved1 uintptr
22
23	xGReserved2 uintptr
24
25	xGReserved3 uintptr
26
27	xGReserved4 uintptr
28
29	xGReserved5 uintptr
30
31	xGReserved6 uintptr
32
33	xGReserved7 uintptr
34
35	xGReserved8 uintptr
36
37	xGReserved9 uintptr
38
39	xGReserved10 uintptr
40}
41
42func (x *SocketClass) GoPointer() uintptr {
43	return uintptr(unsafe.Pointer(x))
44}
45
46// OverrideGReserved1 sets the "_g_reserved1" callback function.
47func (x *SocketClass) OverrideGReserved1(cb func()) {
48	if cb == nil {
49		x.xGReserved1 = 0
50	} else {
51		x.xGReserved1 = purego.NewCallback(func() {
52			cb()
53		})
54	}
55}
56
57// GetGReserved1 gets the "_g_reserved1" callback function.
58func (x *SocketClass) GetGReserved1() func() {
59	if x.xGReserved1 == 0 {
60		return nil
61	}
62	var rawCallback func()
63	purego.RegisterFunc(&rawCallback, x.xGReserved1)
64	return func() {
65		rawCallback()
66	}
67}
68
69// OverrideGReserved2 sets the "_g_reserved2" callback function.
70func (x *SocketClass) OverrideGReserved2(cb func()) {
71	if cb == nil {
72		x.xGReserved2 = 0
73	} else {
74		x.xGReserved2 = purego.NewCallback(func() {
75			cb()
76		})
77	}
78}
79
80// GetGReserved2 gets the "_g_reserved2" callback function.
81func (x *SocketClass) GetGReserved2() func() {
82	if x.xGReserved2 == 0 {
83		return nil
84	}
85	var rawCallback func()
86	purego.RegisterFunc(&rawCallback, x.xGReserved2)
87	return func() {
88		rawCallback()
89	}
90}
91
92// OverrideGReserved3 sets the "_g_reserved3" callback function.
93func (x *SocketClass) OverrideGReserved3(cb func()) {
94	if cb == nil {
95		x.xGReserved3 = 0
96	} else {
97		x.xGReserved3 = purego.NewCallback(func() {
98			cb()
99		})
100	}
101}
102
103// GetGReserved3 gets the "_g_reserved3" callback function.
104func (x *SocketClass) GetGReserved3() func() {
105	if x.xGReserved3 == 0 {
106		return nil
107	}
108	var rawCallback func()
109	purego.RegisterFunc(&rawCallback, x.xGReserved3)
110	return func() {
111		rawCallback()
112	}
113}
114
115// OverrideGReserved4 sets the "_g_reserved4" callback function.
116func (x *SocketClass) OverrideGReserved4(cb func()) {
117	if cb == nil {
118		x.xGReserved4 = 0
119	} else {
120		x.xGReserved4 = purego.NewCallback(func() {
121			cb()
122		})
123	}
124}
125
126// GetGReserved4 gets the "_g_reserved4" callback function.
127func (x *SocketClass) GetGReserved4() func() {
128	if x.xGReserved4 == 0 {
129		return nil
130	}
131	var rawCallback func()
132	purego.RegisterFunc(&rawCallback, x.xGReserved4)
133	return func() {
134		rawCallback()
135	}
136}
137
138// OverrideGReserved5 sets the "_g_reserved5" callback function.
139func (x *SocketClass) OverrideGReserved5(cb func()) {
140	if cb == nil {
141		x.xGReserved5 = 0
142	} else {
143		x.xGReserved5 = purego.NewCallback(func() {
144			cb()
145		})
146	}
147}
148
149// GetGReserved5 gets the "_g_reserved5" callback function.
150func (x *SocketClass) GetGReserved5() func() {
151	if x.xGReserved5 == 0 {
152		return nil
153	}
154	var rawCallback func()
155	purego.RegisterFunc(&rawCallback, x.xGReserved5)
156	return func() {
157		rawCallback()
158	}
159}
160
161// OverrideGReserved6 sets the "_g_reserved6" callback function.
162func (x *SocketClass) OverrideGReserved6(cb func()) {
163	if cb == nil {
164		x.xGReserved6 = 0
165	} else {
166		x.xGReserved6 = purego.NewCallback(func() {
167			cb()
168		})
169	}
170}
171
172// GetGReserved6 gets the "_g_reserved6" callback function.
173func (x *SocketClass) GetGReserved6() func() {
174	if x.xGReserved6 == 0 {
175		return nil
176	}
177	var rawCallback func()
178	purego.RegisterFunc(&rawCallback, x.xGReserved6)
179	return func() {
180		rawCallback()
181	}
182}
183
184// OverrideGReserved7 sets the "_g_reserved7" callback function.
185func (x *SocketClass) OverrideGReserved7(cb func()) {
186	if cb == nil {
187		x.xGReserved7 = 0
188	} else {
189		x.xGReserved7 = purego.NewCallback(func() {
190			cb()
191		})
192	}
193}
194
195// GetGReserved7 gets the "_g_reserved7" callback function.
196func (x *SocketClass) GetGReserved7() func() {
197	if x.xGReserved7 == 0 {
198		return nil
199	}
200	var rawCallback func()
201	purego.RegisterFunc(&rawCallback, x.xGReserved7)
202	return func() {
203		rawCallback()
204	}
205}
206
207// OverrideGReserved8 sets the "_g_reserved8" callback function.
208func (x *SocketClass) OverrideGReserved8(cb func()) {
209	if cb == nil {
210		x.xGReserved8 = 0
211	} else {
212		x.xGReserved8 = purego.NewCallback(func() {
213			cb()
214		})
215	}
216}
217
218// GetGReserved8 gets the "_g_reserved8" callback function.
219func (x *SocketClass) GetGReserved8() func() {
220	if x.xGReserved8 == 0 {
221		return nil
222	}
223	var rawCallback func()
224	purego.RegisterFunc(&rawCallback, x.xGReserved8)
225	return func() {
226		rawCallback()
227	}
228}
229
230// OverrideGReserved9 sets the "_g_reserved9" callback function.
231func (x *SocketClass) OverrideGReserved9(cb func()) {
232	if cb == nil {
233		x.xGReserved9 = 0
234	} else {
235		x.xGReserved9 = purego.NewCallback(func() {
236			cb()
237		})
238	}
239}
240
241// GetGReserved9 gets the "_g_reserved9" callback function.
242func (x *SocketClass) GetGReserved9() func() {
243	if x.xGReserved9 == 0 {
244		return nil
245	}
246	var rawCallback func()
247	purego.RegisterFunc(&rawCallback, x.xGReserved9)
248	return func() {
249		rawCallback()
250	}
251}
252
253// OverrideGReserved10 sets the "_g_reserved10" callback function.
254func (x *SocketClass) OverrideGReserved10(cb func()) {
255	if cb == nil {
256		x.xGReserved10 = 0
257	} else {
258		x.xGReserved10 = purego.NewCallback(func() {
259			cb()
260		})
261	}
262}
263
264// GetGReserved10 gets the "_g_reserved10" callback function.
265func (x *SocketClass) GetGReserved10() func() {
266	if x.xGReserved10 == 0 {
267		return nil
268	}
269	var rawCallback func()
270	purego.RegisterFunc(&rawCallback, x.xGReserved10)
271	return func() {
272		rawCallback()
273	}
274}
275
276type SocketPrivate struct {
277	_ structs.HostLayout
278}
279
280func (x *SocketPrivate) GoPointer() uintptr {
281	return uintptr(unsafe.Pointer(x))
282}
283
284// A `GSocket` is a low-level networking primitive. It is a more or less
285// direct mapping of the BSD socket API in a portable GObject based API.
286// It supports both the UNIX socket implementations and winsock2 on Windows.
287//
288// `GSocket` is the platform independent base upon which the higher level
289// network primitives are based. Applications are not typically meant to
290// use it directly, but rather through classes like [class@Gio.SocketClient],
291// [class@Gio.SocketService] and [class@Gio.SocketConnection]. However there may
292// be cases where direct use of `GSocket` is useful.
293//
294// `GSocket` implements the [iface@Gio.Initable] interface, so if it is manually
295// constructed by e.g. [ctor@GObject.Object.new] you must call
296// [method@Gio.Initable.init] and check the results before using the object.
297// This is done automatically in [ctor@Gio.Socket.new] and
298// [ctor@Gio.Socket.new_from_fd], so these functions can return `NULL`.
299//
300// Sockets operate in two general modes, blocking or non-blocking. When
301// in blocking mode all operations (which don’t take an explicit blocking
302// parameter) block until the requested operation
303// is finished or there is an error. In non-blocking mode all calls that
304// would block return immediately with a `G_IO_ERROR_WOULD_BLOCK` error.
305// To know when a call would successfully run you can call
306// [method@Gio.Socket.condition_check], or [method@Gio.Socket.condition_wait].
307// You can also use [method@Gio.Socket.create_source] and attach it to a
308// [type@GLib.MainContext] to get callbacks when I/O is possible.
309// Note that all sockets are always set to non blocking mode in the system, and
310// blocking mode is emulated in `GSocket`.
311//
312// When working in non-blocking mode applications should always be able to
313// handle getting a `G_IO_ERROR_WOULD_BLOCK` error even when some other
314// function said that I/O was possible. This can easily happen in case
315// of a race condition in the application, but it can also happen for other
316// reasons. For instance, on Windows a socket is always seen as writable
317// until a write returns `G_IO_ERROR_WOULD_BLOCK`.
318//
319// `GSocket`s can be either connection oriented or datagram based.
320// For connection oriented types you must first establish a connection by
321// either connecting to an address or accepting a connection from another
322// address. For connectionless socket types the target/source address is
323// specified or received in each I/O operation.
324//
325// All socket file descriptors are set to be close-on-exec.
326//
327// Note that creating a `GSocket` causes the signal `SIGPIPE` to be
328// ignored for the remainder of the program. If you are writing a
329// command-line utility that uses `GSocket`, you may need to take into
330// account the fact that your program will not automatically be killed
331// if it tries to write to `stdout` after it has been closed.
332//
333// Like most other APIs in GLib, `GSocket` is not inherently thread safe. To use
334// a `GSocket` concurrently from multiple threads, you must implement your own
335// locking.
336//
337// ## Nagle’s algorithm
338//
339// Since GLib 2.80, `GSocket` will automatically set the `TCP_NODELAY` option on
340// all `G_SOCKET_TYPE_STREAM` sockets. This disables
341// [Nagle’s algorithm](https://en.wikipedia.org/wiki/Nagle%27s_algorithm) as it
342// typically does more harm than good on modern networks.
343//
344// If your application needs Nagle’s algorithm enabled, call
345// [method@Gio.Socket.set_option] after constructing a `GSocket` to enable it:
346// ```c
347// socket = g_socket_new (…, G_SOCKET_TYPE_STREAM, …);
348// if (socket != NULL)
349//
350//	{
351//	  g_socket_set_option (socket, IPPROTO_TCP, TCP_NODELAY, FALSE, &local_error);
352//	  // handle error if needed
353//	}
354//
355// ```
356type Socket struct {
357	gobject.Object
358}
359
360var xSocketGLibType func() types.GType
361
362func SocketGLibType() types.GType {
363	return xSocketGLibType()
364}
365
366func SocketNewFromInternalPtr(ptr uintptr) *Socket {
367	cls := &Socket{}
368	cls.Ptr = ptr
369	return cls
370}
371
372var xNewSocket func(SocketFamily, SocketType, SocketProtocol, **glib.Error) uintptr
373
374// Creates a new #GSocket with the defined family, type and protocol.
375// If @protocol is 0 (%G_SOCKET_PROTOCOL_DEFAULT) the default protocol type
376// for the family and type is used.
377//
378// The @protocol is a family and type specific int that specifies what
379// kind of protocol to use. #GSocketProtocol lists several common ones.
380// Many families only support one protocol, and use 0 for this, others
381// support several and using 0 means to use the default protocol for
382// the family and type.
383//
384// The protocol id is passed directly to the operating
385// system, so you can use protocols not listed in #GSocketProtocol if you
386// know the protocol number used for it.
387func NewSocket(FamilyVar SocketFamily, TypeVar SocketType, ProtocolVar SocketProtocol) (*Socket, error) {
388	var cls *Socket
389	var cerr *glib.Error
390
391	cret := xNewSocket(FamilyVar, TypeVar, ProtocolVar, &cerr)
392
393	if cret == 0 {
394		return nil, cerr
395	}
396	cls = &Socket{}
397	cls.Ptr = cret
398	if cerr == nil {
399		return cls, nil
400	}
401	return cls, cerr
402
403}
404
405var xNewSocketFromFd func(int, **glib.Error) uintptr
406
407// Creates a new #GSocket from a native file descriptor
408// or winsock SOCKET handle.
409//
410// This reads all the settings from the file descriptor so that
411// all properties should work. Note that the file descriptor
412// will be set to non-blocking mode, independent on the blocking
413// mode of the #GSocket.
414//
415// On success, the returned #GSocket takes ownership of @fd. On failure, the
416// caller must close @fd themselves.
417//
418// Since GLib 2.46, it is no longer a fatal error to call this on a non-socket
419// descriptor.  Instead, a GError will be set with code %G_IO_ERROR_FAILED
420func NewSocketFromFd(FdVar int) (*Socket, error) {
421	var cls *Socket
422	var cerr *glib.Error
423
424	cret := xNewSocketFromFd(FdVar, &cerr)
425
426	if cret == 0 {
427		return nil, cerr
428	}
429	cls = &Socket{}
430	cls.Ptr = cret
431	if cerr == nil {
432		return cls, nil
433	}
434	return cls, cerr
435
436}
437
438var xSocketAccept func(uintptr, uintptr, **glib.Error) uintptr
439
440// Accept incoming connections on a connection-based socket. This removes
441// the first outstanding connection request from the listening socket and
442// creates a #GSocket object for it.
443//
444// The @socket must be bound to a local address with g_socket_bind() and
445// must be listening for incoming connections (g_socket_listen()).
446//
447// If there are no outstanding connections then the operation will block
448// or return %G_IO_ERROR_WOULD_BLOCK if non-blocking I/O is enabled.
449// To be notified of an incoming connection, wait for the %G_IO_IN condition.
450func (x *Socket) Accept(CancellableVar *Cancellable) (*Socket, error) {
451	var cls *Socket
452	var cerr *glib.Error
453
454	cret := xSocketAccept(x.GoPointer(), CancellableVar.GoPointer(), &cerr)
455
456	if cret == 0 {
457		return nil, cerr
458	}
459	cls = &Socket{}
460	cls.Ptr = cret
461	if cerr == nil {
462		return cls, nil
463	}
464	return cls, cerr
465
466}
467
468var xSocketBind func(uintptr, uintptr, bool, **glib.Error) bool
469
470// When a socket is created it is attached to an address family, but it
471// doesn't have an address in this family. g_socket_bind() assigns the
472// address (sometimes called name) of the socket.
473//
474// It is generally required to bind to a local address before you can
475// receive connections. (See g_socket_listen() and g_socket_accept() ).
476// In certain situations, you may also want to bind a socket that will be
477// used to initiate connections, though this is not normally required.
478//
479// If @socket is a TCP socket, then @allow_reuse controls the setting
480// of the `SO_REUSEADDR` socket option; normally it should be %TRUE for
481// server sockets (sockets that you will eventually call
482// g_socket_accept() on), and %FALSE for client sockets. (Failing to
483// set this flag on a server socket may cause g_socket_bind() to return
484// %G_IO_ERROR_ADDRESS_IN_USE if the server program is stopped and then
485// immediately restarted.)
486//
487// If @socket is a UDP socket, then @allow_reuse determines whether or
488// not other UDP sockets can be bound to the same address at the same
489// time. In particular, you can have several UDP sockets bound to the
490// same address, and they will all receive all of the multicast and
491// broadcast packets sent to that address. (The behavior of unicast
492// UDP packets to an address with multiple listeners is not defined.)
493func (x *Socket) Bind(AddressVar *SocketAddress, AllowReuseVar bool) (bool, error) {
494	var cerr *glib.Error
495
496	cret := xSocketBind(x.GoPointer(), AddressVar.GoPointer(), AllowReuseVar, &cerr)
497	if cerr == nil {
498		return cret, nil
499	}
500	return cret, cerr
501
502}
503
504var xSocketCheckConnectResult func(uintptr) bool
505
506// Checks and resets the pending connect error for the socket.
507// This is used to check for errors when g_socket_connect() is
508// used in non-blocking mode.
509func (x *Socket) CheckConnectResult() (bool, error) {
510	var cerr *glib.Error
511
512	cret := xSocketCheckConnectResult(x.GoPointer())
513	if cerr == nil {
514		return cret, nil
515	}
516	return cret, cerr
517
518}
519
520var xSocketClose func(uintptr) bool
521
522// Closes the socket, shutting down any active connection.
523//
524// Closing a socket does not wait for all outstanding I/O operations
525// to finish, so the caller should not rely on them to be guaranteed
526// to complete even if the close returns with no error.
527//
528// Once the socket is closed, all other operations will return
529// %G_IO_ERROR_CLOSED. Closing a socket multiple times will not
530// return an error.
531//
532// Sockets will be automatically closed when the last reference
533// is dropped, but you might want to call this function to make sure
534// resources are released as early as possible.
535//
536// Beware that due to the way that TCP works, it is possible for
537// recently-sent data to be lost if either you close a socket while the
538// %G_IO_IN condition is set, or else if the remote connection tries to
539// send something to you after you close the socket but before it has
540// finished reading all of the data you sent. There is no easy generic
541// way to avoid this problem; the easiest fix is to design the network
542// protocol such that the client will never send data "out of turn".
543// Another solution is for the server to half-close the connection by
544// calling g_socket_shutdown() with only the @shutdown_write flag set,
545// and then wait for the client to notice this and close its side of the
546// connection, after which the server can safely call g_socket_close().
547// (This is what #GTcpConnection does if you call
548// g_tcp_connection_set_graceful_disconnect(). But of course, this
549// only works if the client will close its connection after the server
550// does.)
551func (x *Socket) Close() (bool, error) {
552	var cerr *glib.Error
553
554	cret := xSocketClose(x.GoPointer())
555	if cerr == nil {
556		return cret, nil
557	}
558	return cret, cerr
559
560}
561
562var xSocketConditionCheck func(uintptr, glib.IOCondition) glib.IOCondition
563
564// Checks on the readiness of @socket to perform operations.
565// The operations specified in @condition are checked for and masked
566// against the currently-satisfied conditions on @socket. The result
567// is returned.
568//
569// Note that on Windows, it is possible for an operation to return
570// %G_IO_ERROR_WOULD_BLOCK even immediately after
571// g_socket_condition_check() has claimed that the socket is ready for
572// writing. Rather than calling g_socket_condition_check() and then
573// writing to the socket if it succeeds, it is generally better to
574// simply try writing to the socket right away, and try again later if
575// the initial attempt returns %G_IO_ERROR_WOULD_BLOCK.
576//
577// It is meaningless to specify %G_IO_ERR or %G_IO_HUP in condition;
578// these conditions will always be set in the output if they are true.
579//
580// This call never blocks.
581func (x *Socket) ConditionCheck(ConditionVar glib.IOCondition) glib.IOCondition {
582
583	cret := xSocketConditionCheck(x.GoPointer(), ConditionVar)
584	return cret
585}
586
587var xSocketConditionTimedWait func(uintptr, glib.IOCondition, int64, uintptr, **glib.Error) bool
588
589// Waits for up to @timeout_us microseconds for @condition to become true
590// on @socket. If the condition is met, %TRUE is returned.
591//
592// If @cancellable is cancelled before the condition is met, or if
593// @timeout_us (or the socket's #GSocket:timeout) is reached before the
594// condition is met, then %FALSE is returned and @error, if non-%NULL,
595// is set to the appropriate value (%G_IO_ERROR_CANCELLED or
596// %G_IO_ERROR_TIMED_OUT).
597//
598// If you don't want a timeout, use g_socket_condition_wait().
599// (Alternatively, you can pass -1 for @timeout_us.)
600//
601// Note that although @timeout_us is in microseconds for consistency with
602// other GLib APIs, this function actually only has millisecond
603// resolution, and the behavior is undefined if @timeout_us is not an
604// exact number of milliseconds.
605func (x *Socket) ConditionTimedWait(ConditionVar glib.IOCondition, TimeoutUsVar int64, CancellableVar *Cancellable) (bool, error) {
606	var cerr *glib.Error
607
608	cret := xSocketConditionTimedWait(x.GoPointer(), ConditionVar, TimeoutUsVar, CancellableVar.GoPointer(), &cerr)
609	if cerr == nil {
610		return cret, nil
611	}
612	return cret, cerr
613
614}
615
616var xSocketConditionWait func(uintptr, glib.IOCondition, uintptr, **glib.Error) bool
617
618// Waits for @condition to become true on @socket. When the condition
619// is met, %TRUE is returned.
620//
621// If @cancellable is cancelled before the condition is met, or if the
622// socket has a timeout set and it is reached before the condition is
623// met, then %FALSE is returned and @error, if non-%NULL, is set to
624// the appropriate value (%G_IO_ERROR_CANCELLED or
625// %G_IO_ERROR_TIMED_OUT).
626//
627// See also g_socket_condition_timed_wait().
628func (x *Socket) ConditionWait(ConditionVar glib.IOCondition, CancellableVar *Cancellable) (bool, error) {
629	var cerr *glib.Error
630
631	cret := xSocketConditionWait(x.GoPointer(), ConditionVar, CancellableVar.GoPointer(), &cerr)
632	if cerr == nil {
633		return cret, nil
634	}
635	return cret, cerr
636
637}
638
639var xSocketConnect func(uintptr, uintptr, uintptr, **glib.Error) bool
640
641// Connect the socket to the specified remote address.
642//
643// For connection oriented socket this generally means we attempt to make
644// a connection to the @address. For a connection-less socket it sets
645// the default address for g_socket_send() and discards all incoming datagrams
646// from other sources.
647//
648// Generally connection oriented sockets can only connect once, but
649// connection-less sockets can connect multiple times to change the
650// default address.
651//
652// If the connect call needs to do network I/O it will block, unless
653// non-blocking I/O is enabled. Then %G_IO_ERROR_PENDING is returned
654// and the user can be notified of the connection finishing by waiting
655// for the G_IO_OUT condition. The result of the connection must then be
656// checked with g_socket_check_connect_result().
657func (x *Socket) Connect(AddressVar *SocketAddress, CancellableVar *Cancellable) (bool, error) {
658	var cerr *glib.Error
659
660	cret := xSocketConnect(x.GoPointer(), AddressVar.GoPointer(), CancellableVar.GoPointer(), &cerr)
661	if cerr == nil {
662		return cret, nil
663	}
664	return cret, cerr
665
666}
667
668var xSocketConnectionFactoryCreateConnection func(uintptr) uintptr
669
670// Creates a #GSocketConnection subclass of the right type for
671// @socket.
672func (x *Socket) ConnectionFactoryCreateConnection() *SocketConnection {
673	var cls *SocketConnection
674
675	cret := xSocketConnectionFactoryCreateConnection(x.GoPointer())
676
677	if cret == 0 {
678		return nil
679	}
680	cls = &SocketConnection{}
681	cls.Ptr = cret
682	return cls
683}
684
685var xSocketCreateSource func(uintptr, glib.IOCondition, uintptr) *glib.Source
686
687// Creates a #GSource that can be attached to a %GMainContext to monitor
688// for the availability of the specified @condition on the socket. The #GSource
689// keeps a reference to the @socket.
690//
691// The callback on the source is of the #GSocketSourceFunc type.
692//
693// It is meaningless to specify %G_IO_ERR or %G_IO_HUP in @condition;
694// these conditions will always be reported output if they are true.
695//
696// @cancellable if not %NULL can be used to cancel the source, which will
697// cause the source to trigger, reporting the current condition (which
698// is likely 0 unless cancellation happened at the same time as a
699// condition change). You can check for this in the callback using
700// g_cancellable_is_cancelled().
701//
702// If @socket has a timeout set, and it is reached before @condition
703// occurs, the source will then trigger anyway, reporting %G_IO_IN or
704// %G_IO_OUT depending on @condition. However, @socket will have been
705// marked as having had a timeout, and so the next #GSocket I/O method
706// you call will then fail with a %G_IO_ERROR_TIMED_OUT.
707func (x *Socket) CreateSource(ConditionVar glib.IOCondition, CancellableVar *Cancellable) *glib.Source {
708
709	cret := xSocketCreateSource(x.GoPointer(), ConditionVar, CancellableVar.GoPointer())
710	return cret
711}
712
713var xSocketGetAvailableBytes func(uintptr) int
714
715// Get the amount of data pending in the OS input buffer, without blocking.
716//
717// If @socket is a UDP or SCTP socket, this will return the size of
718// just the next packet, even if additional packets are buffered after
719// that one.
720//
721// Note that on Windows, this function is rather inefficient in the
722// UDP case, and so if you know any plausible upper bound on the size
723// of the incoming packet, it is better to just do a
724// g_socket_receive() with a buffer of that size, rather than calling
725// g_socket_get_available_bytes() first and then doing a receive of
726// exactly the right size.
727func (x *Socket) GetAvailableBytes() int {
728
729	cret := xSocketGetAvailableBytes(x.GoPointer())
730	return cret
731}
732
733var xSocketGetBlocking func(uintptr) bool
734
735// Gets the blocking mode of the socket. For details on blocking I/O,
736// see g_socket_set_blocking().
737func (x *Socket) GetBlocking() bool {
738
739	cret := xSocketGetBlocking(x.GoPointer())
740	return cret
741}
742
743var xSocketGetBroadcast func(uintptr) bool
744
745// Gets the broadcast setting on @socket; if %TRUE,
746// it is possible to send packets to broadcast
747// addresses.
748func (x *Socket) GetBroadcast() bool {
749
750	cret := xSocketGetBroadcast(x.GoPointer())
751	return cret
752}
753
754var xSocketGetCredentials func(uintptr) uintptr
755
756// Returns the credentials of the foreign process connected to this
757// socket, if any (e.g. it is only supported for %G_SOCKET_FAMILY_UNIX
758// sockets).
759//
760// If this operation isn't supported on the OS, the method fails with
761// the %G_IO_ERROR_NOT_SUPPORTED error. On Linux this is implemented
762// by reading the %SO_PEERCRED option on the underlying socket.
763//
764// This method can be expected to be available on the following platforms:
765//
766// - Linux since GLib 2.26
767// - OpenBSD since GLib 2.30
768// - Solaris, Illumos and OpenSolaris since GLib 2.40
769// - NetBSD since GLib 2.42
770// - macOS, tvOS, iOS since GLib 2.66
771//
772// Other ways to obtain credentials from a foreign peer includes the
773// #GUnixCredentialsMessage type and
774// g_unix_connection_send_credentials() /
775// g_unix_connection_receive_credentials() functions.
776func (x *Socket) GetCredentials() (*Credentials, error) {
777	var cls *Credentials
778	var cerr *glib.Error
779
780	cret := xSocketGetCredentials(x.GoPointer())
781
782	if cret == 0 {
783		return nil, cerr
784	}
785	cls = &Credentials{}
786	cls.Ptr = cret
787	if cerr == nil {
788		return cls, nil
789	}
790	return cls, cerr
791
792}
793
794var xSocketGetFamily func(uintptr) SocketFamily
795
796// Gets the socket family of the socket.
797func (x *Socket) GetFamily() SocketFamily {
798
799	cret := xSocketGetFamily(x.GoPointer())
800	return cret
801}
802
803var xSocketGetFd func(uintptr) int
804
805// Returns the underlying OS socket object. On unix this
806// is a socket file descriptor, and on Windows this is
807// a Winsock2 SOCKET handle. This may be useful for
808// doing platform specific or otherwise unusual operations
809// on the socket.
810func (x *Socket) GetFd() int {
811
812	cret := xSocketGetFd(x.GoPointer())
813	return cret
814}
815
816var xSocketGetKeepalive func(uintptr) bool
817
818// Gets the keepalive mode of the socket. For details on this,
819// see g_socket_set_keepalive().
820func (x *Socket) GetKeepalive() bool {
821
822	cret := xSocketGetKeepalive(x.GoPointer())
823	return cret
824}
825
826var xSocketGetListenBacklog func(uintptr) int
827
828// Gets the listen backlog setting of the socket. For details on this,
829// see g_socket_set_listen_backlog().
830func (x *Socket) GetListenBacklog() int {
831
832	cret := xSocketGetListenBacklog(x.GoPointer())
833	return cret
834}
835
836var xSocketGetLocalAddress func(uintptr) uintptr
837
838// Try to get the local address of a bound socket. This is only
839// useful if the socket has been bound to a local address,
840// either explicitly or implicitly when connecting.
841func (x *Socket) GetLocalAddress() (*SocketAddress, error) {
842	var cls *SocketAddress
843	var cerr *glib.Error
844
845	cret := xSocketGetLocalAddress(x.GoPointer())
846
847	if cret == 0 {
848		return nil, cerr
849	}
850	cls = &SocketAddress{}
851	cls.Ptr = cret
852	if cerr == nil {
853		return cls, nil
854	}
855	return cls, cerr
856
857}
858
859var xSocketGetMulticastLoopback func(uintptr) bool
860
861// Gets the multicast loopback setting on @socket; if %TRUE (the
862// default), outgoing multicast packets will be looped back to
863// multicast listeners on the same host.
864func (x *Socket) GetMulticastLoopback() bool {
865
866	cret := xSocketGetMulticastLoopback(x.GoPointer())
867	return cret
868}
869
870var xSocketGetMulticastTtl func(uintptr) uint
871
872// Gets the multicast time-to-live setting on @socket; see
873// g_socket_set_multicast_ttl() for more details.
874func (x *Socket) GetMulticastTtl() uint {
875
876	cret := xSocketGetMulticastTtl(x.GoPointer())
877	return cret
878}
879
880var xSocketGetOption func(uintptr, int, int, *int, **glib.Error) bool
881
882// Gets the value of an integer-valued option on @socket, as with
883// getsockopt(). (If you need to fetch a  non-integer-valued option,
884// you will need to call getsockopt() directly.)
885//
886// The [`<gio/gnetworking.h>`](networking.html)
887// header pulls in system headers that will define most of the
888// standard/portable socket options. For unusual socket protocols or
889// platform-dependent options, you may need to include additional
890// headers.
891//
892// Note that even for socket options that are a single byte in size,
893// @value is still a pointer to a #gint variable, not a #guchar;
894// g_socket_get_option() will handle the conversion internally.
895func (x *Socket) GetOption(LevelVar int, OptnameVar int, ValueVar *int) (bool, error) {
896	var cerr *glib.Error
897
898	cret := xSocketGetOption(x.GoPointer(), LevelVar, OptnameVar, ValueVar, &cerr)
899	if cerr == nil {
900		return cret, nil
901	}
902	return cret, cerr
903
904}
905
906var xSocketGetProtocol func(uintptr) SocketProtocol
907
908// Gets the socket protocol id the socket was created with.
909// In case the protocol is unknown, -1 is returned.
910func (x *Socket) GetProtocol() SocketProtocol {
911
912	cret := xSocketGetProtocol(x.GoPointer())
913	return cret
914}
915
916var xSocketGetRemoteAddress func(uintptr) uintptr
917
918// Try to get the remote address of a connected socket. This is only
919// useful for connection oriented sockets that have been connected.
920func (x *Socket) GetRemoteAddress() (*SocketAddress, error) {
921	var cls *SocketAddress
922	var cerr *glib.Error
923
924	cret := xSocketGetRemoteAddress(x.GoPointer())
925
926	if cret == 0 {
927		return nil, cerr
928	}
929	cls = &SocketAddress{}
930	cls.Ptr = cret
931	if cerr == nil {
932		return cls, nil
933	}
934	return cls, cerr
935
936}
937
938var xSocketGetSocketType func(uintptr) SocketType
939
940// Gets the socket type of the socket.
941func (x *Socket) GetSocketType() SocketType {
942
943	cret := xSocketGetSocketType(x.GoPointer())
944	return cret
945}
946
947var xSocketGetTimeout func(uintptr) uint
948
949// Gets the timeout setting of the socket. For details on this, see
950// g_socket_set_timeout().
951func (x *Socket) GetTimeout() uint {
952
953	cret := xSocketGetTimeout(x.GoPointer())
954	return cret
955}
956
957var xSocketGetTtl func(uintptr) uint
958
959// Gets the unicast time-to-live setting on @socket; see
960// g_socket_set_ttl() for more details.
961func (x *Socket) GetTtl() uint {
962
963	cret := xSocketGetTtl(x.GoPointer())
964	return cret
965}
966
967var xSocketIsClosed func(uintptr) bool
968
969// Checks whether a socket is closed.
970func (x *Socket) IsClosed() bool {
971
972	cret := xSocketIsClosed(x.GoPointer())
973	return cret
974}
975
976var xSocketIsConnected func(uintptr) bool
977
978// Check whether the socket is connected. This is only useful for
979// connection-oriented sockets.
980//
981// If using g_socket_shutdown(), this function will return %TRUE until the
982// socket has been shut down for reading and writing. If you do a non-blocking
983// connect, this function will not return %TRUE until after you call
984// g_socket_check_connect_result().
985func (x *Socket) IsConnected() bool {
986
987	cret := xSocketIsConnected(x.GoPointer())
988	return cret
989}
990
991var xSocketJoinMulticastGroup func(uintptr, uintptr, bool, uintptr, **glib.Error) bool
992
993// Registers @socket to receive multicast messages sent to @group.
994// @socket must be a %G_SOCKET_TYPE_DATAGRAM socket, and must have
995// been bound to an appropriate interface and port with
996// g_socket_bind().
997//
998// If @iface is %NULL, the system will automatically pick an interface
999// to bind to based on @group.
1000//
1001// If @source_specific is %TRUE, source-specific multicast as defined
1002// in RFC 4604 is used. Note that on older platforms this may fail
1003// with a %G_IO_ERROR_NOT_SUPPORTED error.
1004//
1005// To bind to a given source-specific multicast address, use
1006// g_socket_join_multicast_group_ssm() instead.
1007func (x *Socket) JoinMulticastGroup(GroupVar *InetAddress, SourceSpecificVar bool, IfaceVar *string) (bool, error) {
1008	var cerr *glib.Error
1009
1010	IfaceVarPtr := core.GStrdupNullable(IfaceVar)
1011	defer core.GFreeNullable(IfaceVarPtr)
1012
1013	cret := xSocketJoinMulticastGroup(x.GoPointer(), GroupVar.GoPointer(), SourceSpecificVar, IfaceVarPtr, &cerr)
1014	if cerr == nil {
1015		return cret, nil
1016	}
1017	return cret, cerr
1018
1019}
1020
1021var xSocketJoinMulticastGroupSsm func(uintptr, uintptr, uintptr, uintptr, **glib.Error) bool
1022
1023// Registers @socket to receive multicast messages sent to @group.
1024// @socket must be a %G_SOCKET_TYPE_DATAGRAM socket, and must have
1025// been bound to an appropriate interface and port with
1026// g_socket_bind().
1027//
1028// If @iface is %NULL, the system will automatically pick an interface
1029// to bind to based on @group.
1030//
1031// If @source_specific is not %NULL, use source-specific multicast as
1032// defined in RFC 4604. Note that on older platforms this may fail
1033// with a %G_IO_ERROR_NOT_SUPPORTED error.
1034//
1035// Note that this function can be called multiple times for the same
1036// @group with different @source_specific in order to receive multicast
1037// packets from more than one source.
1038func (x *Socket) JoinMulticastGroupSsm(GroupVar *InetAddress, SourceSpecificVar *InetAddress, IfaceVar *string) (bool, error) {
1039	var cerr *glib.Error
1040
1041	IfaceVarPtr := core.GStrdupNullable(IfaceVar)
1042	defer core.GFreeNullable(IfaceVarPtr)
1043
1044	cret := xSocketJoinMulticastGroupSsm(x.GoPointer(), GroupVar.GoPointer(), SourceSpecificVar.GoPointer(), IfaceVarPtr, &cerr)
1045	if cerr == nil {
1046		return cret, nil
1047	}
1048	return cret, cerr
1049
1050}
1051
1052var xSocketLeaveMulticastGroup func(uintptr, uintptr, bool, uintptr, **glib.Error) bool
1053
1054// Removes @socket from the multicast group defined by @group, @iface,
1055// and @source_specific (which must all have the same values they had
1056// when you joined the group).
1057//
1058// @socket remains bound to its address and port, and can still receive
1059// unicast messages after calling this.
1060//
1061// To unbind to a given source-specific multicast address, use
1062// g_socket_leave_multicast_group_ssm() instead.
1063func (x *Socket) LeaveMulticastGroup(GroupVar *InetAddress, SourceSpecificVar bool, IfaceVar *string) (bool, error) {
1064	var cerr *glib.Error
1065
1066	IfaceVarPtr := core.GStrdupNullable(IfaceVar)
1067	defer core.GFreeNullable(IfaceVarPtr)
1068
1069	cret := xSocketLeaveMulticastGroup(x.GoPointer(), GroupVar.GoPointer(), SourceSpecificVar, IfaceVarPtr, &cerr)
1070	if cerr == nil {
1071		return cret, nil
1072	}
1073	return cret, cerr
1074
1075}
1076
1077var xSocketLeaveMulticastGroupSsm func(uintptr, uintptr, uintptr, uintptr, **glib.Error) bool
1078
1079// Removes @socket from the multicast group defined by @group, @iface,
1080// and @source_specific (which must all have the same values they had
1081// when you joined the group).
1082//
1083// @socket remains bound to its address and port, and can still receive
1084// unicast messages after calling this.
1085func (x *Socket) LeaveMulticastGroupSsm(GroupVar *InetAddress, SourceSpecificVar *InetAddress, IfaceVar *string) (bool, error) {
1086	var cerr *glib.Error
1087
1088	IfaceVarPtr := core.GStrdupNullable(IfaceVar)
1089	defer core.GFreeNullable(IfaceVarPtr)
1090
1091	cret := xSocketLeaveMulticastGroupSsm(x.GoPointer(), GroupVar.GoPointer(), SourceSpecificVar.GoPointer(), IfaceVarPtr, &cerr)
1092	if cerr == nil {
1093		return cret, nil
1094	}
1095	return cret, cerr
1096
1097}
1098
1099var xSocketListen func(uintptr) bool
1100
1101// Marks the socket as a server socket, i.e. a socket that is used
1102// to accept incoming requests using g_socket_accept().
1103//
1104// Before calling this the socket must be bound to a local address using
1105// g_socket_bind().
1106//
1107// To set the maximum amount of outstanding clients, use
1108// g_socket_set_listen_backlog().
1109func (x *Socket) Listen() (bool, error) {
1110	var cerr *glib.Error
1111
1112	cret := xSocketListen(x.GoPointer())
1113	if cerr == nil {
1114		return cret, nil
1115	}
1116	return cret, cerr
1117
1118}
1119
1120var xSocketReceive func(uintptr, *[]byte, uint, uintptr, **glib.Error) int
1121
1122// Receive data (up to @size bytes) from a socket. This is mainly used by
1123// connection-oriented sockets; it is identical to g_socket_receive_from()
1124// with @address set to %NULL.
1125//
1126// For %G_SOCKET_TYPE_DATAGRAM and %G_SOCKET_TYPE_SEQPACKET sockets,
1127// g_socket_receive() will always read either 0 or 1 complete messages from
1128// the socket. If the received message is too large to fit in @buffer, then
1129// the data beyond @size bytes will be discarded, without any explicit
1130// indication that this has occurred.
1131//
1132// For %G_SOCKET_TYPE_STREAM sockets, g_socket_receive() can return any
1133// number of bytes, up to @size. If more than @size bytes have been
1134// received, the additional data will be returned in future calls to
1135// g_socket_receive().
1136//
1137// If the socket is in blocking mode the call will block until there
1138// is some data to receive, the connection is closed, or there is an
1139// error. If there is no data available and the socket is in
1140// non-blocking mode, a %G_IO_ERROR_WOULD_BLOCK error will be
1141// returned. To be notified when data is available, wait for the
1142// %G_IO_IN condition.
1143//
1144// On error -1 is returned and @error is set accordingly.
1145func (x *Socket) Receive(BufferVar *[]byte, SizeVar uint, CancellableVar *Cancellable) (int, error) {
1146	var cerr *glib.Error
1147
1148	cret := xSocketReceive(x.GoPointer(), BufferVar, SizeVar, CancellableVar.GoPointer(), &cerr)
1149	if cerr == nil {
1150		return cret, nil
1151	}
1152	return cret, cerr
1153
1154}
1155
1156var xSocketReceiveBytes func(uintptr, uint, int64, uintptr, **glib.Error) *glib.Bytes
1157
1158// Receives data (up to @size bytes) from a socket.
1159//
1160// This function is a variant of [method@Gio.Socket.receive] which returns a
1161// [struct@GLib.Bytes] rather than a plain buffer.
1162//
1163// Pass `-1` to @timeout_us to block indefinitely until data is received (or
1164// the connection is closed, or there is an error). Pass `0` to use the default
1165// timeout from [property@Gio.Socket:timeout], or pass a positive number to wait
1166// for that many microseconds for data before returning `G_IO_ERROR_TIMED_OUT`.
1167func (x *Socket) ReceiveBytes(SizeVar uint, TimeoutUsVar int64, CancellableVar *Cancellable) (*glib.Bytes, error) {
1168	var cerr *glib.Error
1169
1170	cret := xSocketReceiveBytes(x.GoPointer(), SizeVar, TimeoutUsVar, CancellableVar.GoPointer(), &cerr)
1171	if cerr == nil {
1172		return cret, nil
1173	}
1174	return cret, cerr
1175
1176}
1177
1178var xSocketReceiveBytesFrom func(uintptr, **SocketAddress, uint, int64, uintptr, **glib.Error) *glib.Bytes
1179
1180// Receive data (up to @size bytes) from a socket.
1181//
1182// This function is a variant of [method@Gio.Socket.receive_from] which returns
1183// a [struct@GLib.Bytes] rather than a plain buffer.
1184//
1185// If @address is non-%NULL then @address will be set equal to the
1186// source address of the received packet.
1187//
1188// The @address is owned by the caller.
1189//
1190// Pass `-1` to @timeout_us to block indefinitely until data is received (or
1191// the connection is closed, or there is an error). Pass `0` to use the default
1192// timeout from [property@Gio.Socket:timeout], or pass a positive number to wait
1193// for that many microseconds for data before returning `G_IO_ERROR_TIMED_OUT`.
1194func (x *Socket) ReceiveBytesFrom(AddressVar **SocketAddress, SizeVar uint, TimeoutUsVar int64, CancellableVar *Cancellable) (*glib.Bytes, error) {
1195	var cerr *glib.Error
1196
1197	cret := xSocketReceiveBytesFrom(x.GoPointer(), AddressVar, SizeVar, TimeoutUsVar, CancellableVar.GoPointer(), &cerr)
1198	if cerr == nil {
1199		return cret, nil
1200	}
1201	return cret, cerr
1202
1203}
1204
1205var xSocketReceiveFrom func(uintptr, **SocketAddress, *[]byte, uint, uintptr, **glib.Error) int
1206
1207// Receive data (up to @size bytes) from a socket.
1208//
1209// If @address is non-%NULL then @address will be set equal to the
1210// source address of the received packet.
1211// @address is owned by the caller.
1212//
1213// See g_socket_receive() for additional information.
1214func (x *Socket) ReceiveFrom(AddressVar **SocketAddress, BufferVar *[]byte, SizeVar uint, CancellableVar *Cancellable) (int, error) {
1215	var cerr *glib.Error
1216
1217	cret := xSocketReceiveFrom(x.GoPointer(), AddressVar, BufferVar, SizeVar, CancellableVar.GoPointer(), &cerr)
1218	if cerr == nil {
1219		return cret, nil
1220	}
1221	return cret, cerr
1222
1223}
1224
1225var xSocketReceiveMessage func(uintptr, **SocketAddress, []InputVector, int, *uintptr, *int, *int, uintptr, **glib.Error) int
1226
1227// Receive data from a socket.  For receiving multiple messages, see
1228// g_socket_receive_messages(); for easier use, see
1229// g_socket_receive() and g_socket_receive_from().
1230//
1231// If @address is non-%NULL then @address will be set equal to the
1232// source address of the received packet.
1233// @address is owned by the caller.
1234//
1235// @vector must point to an array of #GInputVector structs and
1236// @num_vectors must be the length of this array.  These structs
1237// describe the buffers that received data will be scattered into.
1238// If @num_vectors is -1, then @vectors is assumed to be terminated
1239// by a #GInputVector with a %NULL buffer pointer.
1240//
1241// As a special case, if @num_vectors is 0 (in which case, @vectors
1242// may of course be %NULL), then a single byte is received and
1243// discarded. This is to facilitate the common practice of sending a
1244// single '\0' byte for the purposes of transferring ancillary data.
1245//
1246// @messages, if non-%NULL, will be set to point to a newly-allocated
1247// array of #GSocketControlMessage instances or %NULL if no such
1248// messages was received. These correspond to the control messages
1249// received from the kernel, one #GSocketControlMessage per message
1250// from the kernel. This array is %NULL-terminated and must be freed
1251// by the caller using g_free() after calling g_object_unref() on each
1252// element. If @messages is %NULL, any control messages received will
1253// be discarded.
1254//
1255// @num_messages, if non-%NULL, will be set to the number of control
1256// messages received.
1257//
1258// If both @messages and @num_messages are non-%NULL, then
1259// @num_messages gives the number of #GSocketControlMessage instances
1260// in @messages (ie: not including the %NULL terminator).
1261//
1262// @flags is an in/out parameter. The commonly available arguments
1263// for this are available in the #GSocketMsgFlags enum, but the
1264// values there are the same as the system values, and the flags
1265// are passed in as-is, so you can pass in system-specific flags too
1266// (and g_socket_receive_message() may pass system-specific flags out).
1267// Flags passed in to the parameter affect the receive operation; flags returned
1268// out of it are relevant to the specific returned message.
1269//
1270// As with g_socket_receive(), data may be discarded if @socket is
1271// %G_SOCKET_TYPE_DATAGRAM or %G_SOCKET_TYPE_SEQPACKET and you do not
1272// provide enough buffer space to read a complete message. You can pass
1273// %G_SOCKET_MSG_PEEK in @flags to peek at the current message without
1274// removing it from the receive queue, but there is no portable way to find
1275// out the length of the message other than by reading it into a
1276// sufficiently-large buffer.
1277//
1278// If the socket is in blocking mode the call will block until there
1279// is some data to receive, the connection is closed, or there is an
1280// error. If there is no data available and the socket is in
1281// non-blocking mode, a %G_IO_ERROR_WOULD_BLOCK error will be
1282// returned. To be notified when data is available, wait for the
1283// %G_IO_IN condition.
1284//
1285// On error -1 is returned and @error is set accordingly.
1286func (x *Socket) ReceiveMessage(AddressVar **SocketAddress, VectorsVar []InputVector, NumVectorsVar int, MessagesVar *uintptr, NumMessagesVar *int, FlagsVar *int, CancellableVar *Cancellable) (int, error) {
1287	var cerr *glib.Error
1288
1289	cret := xSocketReceiveMessage(x.GoPointer(), AddressVar, VectorsVar, NumVectorsVar, MessagesVar, NumMessagesVar, FlagsVar, CancellableVar.GoPointer(), &cerr)
1290	if cerr == nil {
1291		return cret, nil
1292	}
1293	return cret, cerr
1294
1295}
1296
1297var xSocketReceiveMessages func(uintptr, []InputMessage, uint, int, uintptr, **glib.Error) int
1298
1299// Receive multiple data messages from @socket in one go.  This is the most
1300// complicated and fully-featured version of this call. For easier use, see
1301// g_socket_receive(), g_socket_receive_from(), and g_socket_receive_message().
1302//
1303// @messages must point to an array of #GInputMessage structs and
1304// @num_messages must be the length of this array. Each #GInputMessage
1305// contains a pointer to an array of #GInputVector structs describing the
1306// buffers that the data received in each message will be written to. Using
1307// multiple #GInputVectors is more memory-efficient than manually copying data
1308// out of a single buffer to multiple sources, and more system-call-efficient
1309// than making multiple calls to g_socket_receive(), such as in scenarios where
1310// a lot of data packets need to be received (e.g. high-bandwidth video
1311// streaming over RTP/UDP).
1312//
1313// @flags modify how all messages are received. The commonly available
1314// arguments for this are available in the #GSocketMsgFlags enum, but the
1315// values there are the same as the system values, and the flags
1316// are passed in as-is, so you can pass in system-specific flags too. These
1317// flags affect the overall receive operation. Flags affecting individual
1318// messages are returned in #GInputMessage.flags.
1319//
1320// The other members of #GInputMessage are treated as described in its
1321// documentation.
1322//
1323// If #GSocket:blocking is %TRUE the call will block until @num_messages have
1324// been received, or the end of the stream is reached.
1325//
1326// If #GSocket:blocking is %FALSE the call will return up to @num_messages
1327// without blocking, or %G_IO_ERROR_WOULD_BLOCK if no messages are queued in the
1328// operating system to be received.
1329//
1330// In blocking mode, if #GSocket:timeout is positive and is reached before any
1331// messages are received, %G_IO_ERROR_TIMED_OUT is returned, otherwise up to
1332// @num_messages are returned. (Note: This is effectively the
1333// behaviour of `MSG_WAITFORONE` with recvmmsg().)
1334//
1335// To be notified when messages are available, wait for the
1336// %G_IO_IN condition. Note though that you may still receive
1337// %G_IO_ERROR_WOULD_BLOCK from g_socket_receive_messages() even if you were
1338// previously notified of a %G_IO_IN condition.
1339//
1340// If the remote peer closes the connection, any messages queued in the
1341// operating system will be returned, and subsequent calls to
1342// g_socket_receive_messages() will return 0 (with no error set).
1343//
1344// On error -1 is returned and @error is set accordingly. An error will only
1345// be returned if zero messages could be received; otherwise the number of
1346// messages successfully received before the error will be returned.
1347func (x *Socket) ReceiveMessages(MessagesVar []InputMessage, NumMessagesVar uint, FlagsVar int, CancellableVar *Cancellable) (int, error) {
1348	var cerr *glib.Error
1349
1350	cret := xSocketReceiveMessages(x.GoPointer(), MessagesVar, NumMessagesVar, FlagsVar, CancellableVar.GoPointer(), &cerr)
1351	if cerr == nil {
1352		return cret, nil
1353	}
1354	return cret, cerr
1355
1356}
1357
1358var xSocketReceiveWithBlocking func(uintptr, *[]byte, uint, bool, uintptr, **glib.Error) int
1359
1360// This behaves exactly the same as g_socket_receive(), except that
1361// the choice of blocking or non-blocking behavior is determined by
1362// the @blocking argument rather than by @socket's properties.
1363func (x *Socket) ReceiveWithBlocking(BufferVar *[]byte, SizeVar uint, BlockingVar bool, CancellableVar *Cancellable) (int, error) {
1364	var cerr *glib.Error
1365
1366	cret := xSocketReceiveWithBlocking(x.GoPointer(), BufferVar, SizeVar, BlockingVar, CancellableVar.GoPointer(), &cerr)
1367	if cerr == nil {
1368		return cret, nil
1369	}
1370	return cret, cerr
1371
1372}
1373
1374var xSocketSend func(uintptr, []byte, uint, uintptr, **glib.Error) int
1375
1376// Tries to send @size bytes from @buffer on the socket. This is
1377// mainly used by connection-oriented sockets; it is identical to
1378// g_socket_send_to() with @address set to %NULL.
1379//
1380// If the socket is in blocking mode the call will block until there is
1381// space for the data in the socket queue. If there is no space available
1382// and the socket is in non-blocking mode a %G_IO_ERROR_WOULD_BLOCK error
1383// will be returned. To be notified when space is available, wait for the
1384// %G_IO_OUT condition. Note though that you may still receive
1385// %G_IO_ERROR_WOULD_BLOCK from g_socket_send() even if you were previously
1386// notified of a %G_IO_OUT condition. (On Windows in particular, this is
1387// very common due to the way the underlying APIs work.)
1388//
1389// On error -1 is returned and @error is set accordingly.
1390func (x *Socket) Send(BufferVar []byte, SizeVar uint, CancellableVar *Cancellable) (int, error) {
1391	var cerr *glib.Error
1392
1393	cret := xSocketSend(x.GoPointer(), BufferVar, SizeVar, CancellableVar.GoPointer(), &cerr)
1394	if cerr == nil {
1395		return cret, nil
1396	}
1397	return cret, cerr
1398
1399}
1400
1401var xSocketSendMessage func(uintptr, uintptr, []OutputVector, int, uintptr, int, int, uintptr, **glib.Error) int
1402
1403// Send data to @address on @socket.  For sending multiple messages see
1404// g_socket_send_messages(); for easier use, see
1405// g_socket_send() and g_socket_send_to().
1406//
1407// If @address is %NULL then the message is sent to the default receiver
1408// (set by g_socket_connect()).
1409//
1410// @vectors must point to an array of #GOutputVector structs and
1411// @num_vectors must be the length of this array. (If @num_vectors is -1,
1412// then @vectors is assumed to be terminated by a #GOutputVector with a
1413// %NULL buffer pointer.) The #GOutputVector structs describe the buffers
1414// that the sent data will be gathered from. Using multiple
1415// #GOutputVectors is more memory-efficient than manually copying
1416// data from multiple sources into a single buffer, and more
1417// network-efficient than making multiple calls to g_socket_send().
1418//
1419// @messages, if non-%NULL, is taken to point to an array of @num_messages
1420// #GSocketControlMessage instances. These correspond to the control
1421// messages to be sent on the socket.
1422// If @num_messages is -1 then @messages is treated as a %NULL-terminated
1423// array.
1424//
1425// @flags modify how the message is sent. The commonly available arguments
1426// for this are available in the #GSocketMsgFlags enum, but the
1427// values there are the same as the system values, and the flags
1428// are passed in as-is, so you can pass in system-specific flags too.
1429//
1430// If the socket is in blocking mode the call will block until there is
1431// space for the data in the socket queue. If there is no space available
1432// and the socket is in non-blocking mode a %G_IO_ERROR_WOULD_BLOCK error
1433// will be returned. To be notified when space is available, wait for the
1434// %G_IO_OUT condition. Note though that you may still receive
1435// %G_IO_ERROR_WOULD_BLOCK from g_socket_send() even if you were previously
1436// notified of a %G_IO_OUT condition. (On Windows in particular, this is
1437// very common due to the way the underlying APIs work.)
1438//
1439// The sum of the sizes of each #GOutputVector in vectors must not be
1440// greater than %G_MAXSSIZE. If the message can be larger than this,
1441// then it is mandatory to use the g_socket_send_message_with_timeout()
1442// function.
1443//
1444// On error -1 is returned and @error is set accordingly.
1445func (x *Socket) SendMessage(AddressVar *SocketAddress, VectorsVar []OutputVector, NumVectorsVar int, MessagesVar uintptr, NumMessagesVar int, FlagsVar int, CancellableVar *Cancellable) (int, error) {
1446	var cerr *glib.Error
1447
1448	cret := xSocketSendMessage(x.GoPointer(), AddressVar.GoPointer(), VectorsVar, NumVectorsVar, MessagesVar, NumMessagesVar, FlagsVar, CancellableVar.GoPointer(), &cerr)
1449	if cerr == nil {
1450		return cret, nil
1451	}
1452	return cret, cerr
1453
1454}
1455
1456var xSocketSendMessageWithTimeout func(uintptr, uintptr, []OutputVector, int, uintptr, int, int, int64, *uint, uintptr, **glib.Error) PollableReturn
1457
1458// This behaves exactly the same as g_socket_send_message(), except that
1459// the choice of timeout behavior is determined by the @timeout_us argument
1460// rather than by @socket's properties.
1461//
1462// On error %G_POLLABLE_RETURN_FAILED is returned and @error is set accordingly, or
1463// if the socket is currently not writable %G_POLLABLE_RETURN_WOULD_BLOCK is
1464// returned. @bytes_written will contain 0 in both cases.
1465func (x *Socket) SendMessageWithTimeout(AddressVar *SocketAddress, VectorsVar []OutputVector, NumVectorsVar int, MessagesVar uintptr, NumMessagesVar int, FlagsVar int, TimeoutUsVar int64, BytesWrittenVar *uint, CancellableVar *Cancellable) (PollableReturn, error) {
1466	var cerr *glib.Error
1467
1468	cret := xSocketSendMessageWithTimeout(x.GoPointer(), AddressVar.GoPointer(), VectorsVar, NumVectorsVar, MessagesVar, NumMessagesVar, FlagsVar, TimeoutUsVar, BytesWrittenVar, CancellableVar.GoPointer(), &cerr)
1469	if cerr == nil {
1470		return cret, nil
1471	}
1472	return cret, cerr
1473
1474}
1475
1476var xSocketSendMessages func(uintptr, []OutputMessage, uint, int, uintptr, **glib.Error) int
1477
1478// Send multiple data messages from @socket in one go.  This is the most
1479// complicated and fully-featured version of this call. For easier use, see
1480// g_socket_send(), g_socket_send_to(), and g_socket_send_message().
1481//
1482// @messages must point to an array of #GOutputMessage structs and
1483// @num_messages must be the length of this array. Each #GOutputMessage
1484// contains an address to send the data to, and a pointer to an array of
1485// #GOutputVector structs to describe the buffers that the data to be sent
1486// for each message will be gathered from. Using multiple #GOutputVectors is
1487// more memory-efficient than manually copying data from multiple sources
1488// into a single buffer, and more network-efficient than making multiple
1489// calls to g_socket_send(). Sending multiple messages in one go avoids the
1490// overhead of making a lot of syscalls in scenarios where a lot of data
1491// packets need to be sent (e.g. high-bandwidth video streaming over RTP/UDP),
1492// or where the same data needs to be sent to multiple recipients.
1493//
1494// @flags modify how the message is sent. The commonly available arguments
1495// for this are available in the #GSocketMsgFlags enum, but the
1496// values there are the same as the system values, and the flags
1497// are passed in as-is, so you can pass in system-specific flags too.
1498//
1499// If the socket is in blocking mode the call will block until there is
1500// space for all the data in the socket queue. If there is no space available
1501// and the socket is in non-blocking mode a %G_IO_ERROR_WOULD_BLOCK error
1502// will be returned if no data was written at all, otherwise the number of
1503// messages sent will be returned. To be notified when space is available,
1504// wait for the %G_IO_OUT condition. Note though that you may still receive
1505// %G_IO_ERROR_WOULD_BLOCK from g_socket_send() even if you were previously
1506// notified of a %G_IO_OUT condition. (On Windows in particular, this is
1507// very common due to the way the underlying APIs work.)
1508//
1509// On error -1 is returned and @error is set accordingly. An error will only
1510// be returned if zero messages could be sent; otherwise the number of messages
1511// successfully sent before the error will be returned.
1512func (x *Socket) SendMessages(MessagesVar []OutputMessage, NumMessagesVar uint, FlagsVar int, CancellableVar *Cancellable) (int, error) {
1513	var cerr *glib.Error
1514
1515	cret := xSocketSendMessages(x.GoPointer(), MessagesVar, NumMessagesVar, FlagsVar, CancellableVar.GoPointer(), &cerr)
1516	if cerr == nil {
1517		return cret, nil
1518	}
1519	return cret, cerr
1520
1521}
1522
1523var xSocketSendTo func(uintptr, uintptr, []byte, uint, uintptr, **glib.Error) int
1524
1525// Tries to send @size bytes from @buffer to @address. If @address is
1526// %NULL then the message is sent to the default receiver (set by
1527// g_socket_connect()).
1528//
1529// See g_socket_send() for additional information.
1530func (x *Socket) SendTo(AddressVar *SocketAddress, BufferVar []byte, SizeVar uint, CancellableVar *Cancellable) (int, error) {
1531	var cerr *glib.Error
1532
1533	cret := xSocketSendTo(x.GoPointer(), AddressVar.GoPointer(), BufferVar, SizeVar, CancellableVar.GoPointer(), &cerr)
1534	if cerr == nil {
1535		return cret, nil
1536	}
1537	return cret, cerr
1538
1539}
1540
1541var xSocketSendWithBlocking func(uintptr, []byte, uint, bool, uintptr, **glib.Error) int
1542
1543// This behaves exactly the same as g_socket_send(), except that
1544// the choice of blocking or non-blocking behavior is determined by
1545// the @blocking argument rather than by @socket's properties.
1546func (x *Socket) SendWithBlocking(BufferVar []byte, SizeVar uint, BlockingVar bool, CancellableVar *Cancellable) (int, error) {
1547	var cerr *glib.Error
1548
1549	cret := xSocketSendWithBlocking(x.GoPointer(), BufferVar, SizeVar, BlockingVar, CancellableVar.GoPointer(), &cerr)
1550	if cerr == nil {
1551		return cret, nil
1552	}
1553	return cret, cerr
1554
1555}
1556
1557var xSocketSetBlocking func(uintptr, bool)
1558
1559// Sets the blocking mode of the socket. In blocking mode
1560// all operations (which don’t take an explicit blocking parameter) block until
1561// they succeed or there is an error. In
1562// non-blocking mode all functions return results immediately or
1563// with a %G_IO_ERROR_WOULD_BLOCK error.
1564//
1565// All sockets are created in blocking mode. However, note that the
1566// platform level socket is always non-blocking, and blocking mode
1567// is a GSocket level feature.
1568func (x *Socket) SetBlocking(BlockingVar bool) {
1569
1570	xSocketSetBlocking(x.GoPointer(), BlockingVar)
1571
1572}
1573
1574var xSocketSetBroadcast func(uintptr, bool)
1575
1576// Sets whether @socket should allow sending to broadcast addresses.
1577// This is %FALSE by default.
1578func (x *Socket) SetBroadcast(BroadcastVar bool) {
1579
1580	xSocketSetBroadcast(x.GoPointer(), BroadcastVar)
1581
1582}
1583
1584var xSocketSetKeepalive func(uintptr, bool)
1585
1586// Sets or unsets the %SO_KEEPALIVE flag on the underlying socket. When
1587// this flag is set on a socket, the system will attempt to verify that the
1588// remote socket endpoint is still present if a sufficiently long period of
1589// time passes with no data being exchanged. If the system is unable to
1590// verify the presence of the remote endpoint, it will automatically close
1591// the connection.
1592//
1593// This option is only functional on certain kinds of sockets. (Notably,
1594// %G_SOCKET_PROTOCOL_TCP sockets.)
1595//
1596// The exact time between pings is system- and protocol-dependent, but will
1597// normally be at least two hours. Most commonly, you would set this flag
1598// on a server socket if you want to allow clients to remain idle for long
1599// periods of time, but also want to ensure that connections are eventually
1600// garbage-collected if clients crash or become unreachable.
1601func (x *Socket) SetKeepalive(KeepaliveVar bool) {
1602
1603	xSocketSetKeepalive(x.GoPointer(), KeepaliveVar)
1604
1605}
1606
1607var xSocketSetListenBacklog func(uintptr, int)
1608
1609// Sets the maximum number of outstanding connections allowed
1610// when listening on this socket. If more clients than this are
1611// connecting to the socket and the application is not handling them
1612// on time then the new connections will be refused.
1613//
1614// Note that this must be called before g_socket_listen() and has no
1615// effect if called after that.
1616func (x *Socket) SetListenBacklog(BacklogVar int) {
1617
1618	xSocketSetListenBacklog(x.GoPointer(), BacklogVar)
1619
1620}
1621
1622var xSocketSetMulticastLoopback func(uintptr, bool)
1623
1624// Sets whether outgoing multicast packets will be received by sockets
1625// listening on that multicast address on the same host. This is %TRUE
1626// by default.
1627func (x *Socket) SetMulticastLoopback(LoopbackVar bool) {
1628
1629	xSocketSetMulticastLoopback(x.GoPointer(), LoopbackVar)
1630
1631}
1632
1633var xSocketSetMulticastTtl func(uintptr, uint)
1634
1635// Sets the time-to-live for outgoing multicast datagrams on @socket.
1636// By default, this is 1, meaning that multicast packets will not leave
1637// the local network.
1638func (x *Socket) SetMulticastTtl(TtlVar uint) {
1639
1640	xSocketSetMulticastTtl(x.GoPointer(), TtlVar)
1641
1642}
1643
1644var xSocketSetOption func(uintptr, int, int, int, **glib.Error) bool
1645
1646// Sets the value of an integer-valued option on @socket, as with
1647// setsockopt(). (If you need to set a non-integer-valued option,
1648// you will need to call setsockopt() directly.)
1649//
1650// The [`<gio/gnetworking.h>`](networking.html)
1651// header pulls in system headers that will define most of the
1652// standard/portable socket options. For unusual socket protocols or
1653// platform-dependent options, you may need to include additional
1654// headers.
1655func (x *Socket) SetOption(LevelVar int, OptnameVar int, ValueVar int) (bool, error) {
1656	var cerr *glib.Error
1657
1658	cret := xSocketSetOption(x.GoPointer(), LevelVar, OptnameVar, ValueVar, &cerr)
1659	if cerr == nil {
1660		return cret, nil
1661	}
1662	return cret, cerr
1663
1664}
1665
1666var xSocketSetTimeout func(uintptr, uint)
1667
1668// Sets the time in seconds after which I/O operations on @socket will
1669// time out if they have not yet completed.
1670//
1671// On a blocking socket, this means that any blocking #GSocket
1672// operation will time out after @timeout seconds of inactivity,
1673// returning %G_IO_ERROR_TIMED_OUT.
1674//
1675// On a non-blocking socket, calls to g_socket_condition_wait() will
1676// also fail with %G_IO_ERROR_TIMED_OUT after the given time. Sources
1677// created with g_socket_create_source() will trigger after
1678// @timeout seconds of inactivity, with the requested condition
1679// set, at which point calling g_socket_receive(), g_socket_send(),
1680// g_socket_check_connect_result(), etc, will fail with
1681// %G_IO_ERROR_TIMED_OUT.
1682//
1683// If @timeout is 0 (the default), operations will never time out
1684// on their own.
1685//
1686// Note that if an I/O operation is interrupted by a signal, this may
1687// cause the timeout to be reset.
1688func (x *Socket) SetTimeout(TimeoutVar uint) {
1689
1690	xSocketSetTimeout(x.GoPointer(), TimeoutVar)
1691
1692}
1693
1694var xSocketSetTtl func(uintptr, uint)
1695
1696// Sets the time-to-live for outgoing unicast packets on @socket.
1697// By default the platform-specific default value is used.
1698func (x *Socket) SetTtl(TtlVar uint) {
1699
1700	xSocketSetTtl(x.GoPointer(), TtlVar)
1701
1702}
1703
1704var xSocketShutdown func(uintptr, bool, bool, **glib.Error) bool
1705
1706// Shut down part or all of a full-duplex connection.
1707//
1708// If @shutdown_read is %TRUE then the receiving side of the connection
1709// is shut down, and further reading is disallowed.
1710//
1711// If @shutdown_write is %TRUE then the sending side of the connection
1712// is shut down, and further writing is disallowed.
1713//
1714// It is allowed for both @shutdown_read and @shutdown_write to be %TRUE.
1715//
1716// One example where it is useful to shut down only one side of a connection is
1717// graceful disconnect for TCP connections where you close the sending side,
1718// then wait for the other side to close the connection, thus ensuring that the
1719// other side saw all sent data.
1720func (x *Socket) Shutdown(ShutdownReadVar bool, ShutdownWriteVar bool) (bool, error) {
1721	var cerr *glib.Error
1722
1723	cret := xSocketShutdown(x.GoPointer(), ShutdownReadVar, ShutdownWriteVar, &cerr)
1724	if cerr == nil {
1725		return cret, nil
1726	}
1727	return cret, cerr
1728
1729}
1730
1731var xSocketSpeaksIpv4 func(uintptr) bool
1732
1733// Checks if a socket is capable of speaking IPv4.
1734//
1735// IPv4 sockets are capable of speaking IPv4.  On some operating systems
1736// and under some combinations of circumstances IPv6 sockets are also
1737// capable of speaking IPv4.  See RFC 3493 section 3.7 for more
1738// information.
1739//
1740// No other types of sockets are currently considered as being capable
1741// of speaking IPv4.
1742func (x *Socket) SpeaksIpv4() bool {
1743
1744	cret := xSocketSpeaksIpv4(x.GoPointer())
1745	return cret
1746}
1747
1748func (c *Socket) GoPointer() uintptr {
1749	if c == nil {
1750		return 0
1751	}
1752	return c.Ptr
1753}
1754
1755func (c *Socket) SetGoPointer(ptr uintptr) {
1756	c.Ptr = ptr
1757}
1758
1759// SetPropertyBlocking sets the "blocking" property.
1760// Whether I/O on this socket is blocking.
1761func (x *Socket) SetPropertyBlocking(value bool) {
1762	var v gobject.Value
1763	v.Init(gobject.TypeBooleanVal)
1764	v.SetBoolean(value)
1765	x.SetProperty("blocking", &v)
1766}
1767
1768// GetPropertyBlocking gets the "blocking" property.
1769// Whether I/O on this socket is blocking.
1770func (x *Socket) GetPropertyBlocking() bool {
1771	var v gobject.Value
1772	x.GetProperty("blocking", &v)
1773	return v.GetBoolean()
1774}
1775
1776// SetPropertyBroadcast sets the "broadcast" property.
1777// Whether the socket should allow sending to broadcast addresses.
1778func (x *Socket) SetPropertyBroadcast(value bool) {
1779	var v gobject.Value
1780	v.Init(gobject.TypeBooleanVal)
1781	v.SetBoolean(value)
1782	x.SetProperty("broadcast", &v)
1783}
1784
1785// GetPropertyBroadcast gets the "broadcast" property.
1786// Whether the socket should allow sending to broadcast addresses.
1787func (x *Socket) GetPropertyBroadcast() bool {
1788	var v gobject.Value
1789	x.GetProperty("broadcast", &v)
1790	return v.GetBoolean()
1791}
1792
1793// SetPropertyFd sets the "fd" property.
1794// The socket’s file descriptor.
1795func (x *Socket) SetPropertyFd(value int) {
1796	var v gobject.Value
1797	v.Init(gobject.TypeIntVal)
1798	v.SetInt(value)
1799	x.SetProperty("fd", &v)
1800}
1801
1802// GetPropertyFd gets the "fd" property.
1803// The socket’s file descriptor.
1804func (x *Socket) GetPropertyFd() int {
1805	var v gobject.Value
1806	x.GetProperty("fd", &v)
1807	return v.GetInt()
1808}
1809
1810// SetPropertyKeepalive sets the "keepalive" property.
1811// Whether to keep the connection alive by sending periodic pings.
1812func (x *Socket) SetPropertyKeepalive(value bool) {
1813	var v gobject.Value
1814	v.Init(gobject.TypeBooleanVal)
1815	v.SetBoolean(value)
1816	x.SetProperty("keepalive", &v)
1817}
1818
1819// GetPropertyKeepalive gets the "keepalive" property.
1820// Whether to keep the connection alive by sending periodic pings.
1821func (x *Socket) GetPropertyKeepalive() bool {
1822	var v gobject.Value
1823	x.GetProperty("keepalive", &v)
1824	return v.GetBoolean()
1825}
1826
1827// SetPropertyListenBacklog sets the "listen-backlog" property.
1828// The number of outstanding connections in the listen queue.
1829func (x *Socket) SetPropertyListenBacklog(value int) {
1830	var v gobject.Value
1831	v.Init(gobject.TypeIntVal)
1832	v.SetInt(value)
1833	x.SetProperty("listen-backlog", &v)
1834}
1835
1836// GetPropertyListenBacklog gets the "listen-backlog" property.
1837// The number of outstanding connections in the listen queue.
1838func (x *Socket) GetPropertyListenBacklog() int {
1839	var v gobject.Value
1840	x.GetProperty("listen-backlog", &v)
1841	return v.GetInt()
1842}
1843
1844// SetPropertyMulticastLoopback sets the "multicast-loopback" property.
1845// Whether outgoing multicast packets loop back to the local host.
1846func (x *Socket) SetPropertyMulticastLoopback(value bool) {
1847	var v gobject.Value
1848	v.Init(gobject.TypeBooleanVal)
1849	v.SetBoolean(value)
1850	x.SetProperty("multicast-loopback", &v)
1851}
1852
1853// GetPropertyMulticastLoopback gets the "multicast-loopback" property.
1854// Whether outgoing multicast packets loop back to the local host.
1855func (x *Socket) GetPropertyMulticastLoopback() bool {
1856	var v gobject.Value
1857	x.GetProperty("multicast-loopback", &v)
1858	return v.GetBoolean()
1859}
1860
1861// SetPropertyMulticastTtl sets the "multicast-ttl" property.
1862// Time-to-live out outgoing multicast packets
1863func (x *Socket) SetPropertyMulticastTtl(value uint) {
1864	var v gobject.Value
1865	v.Init(gobject.TypeUintVal)
1866	v.SetUint(value)
1867	x.SetProperty("multicast-ttl", &v)
1868}
1869
1870// GetPropertyMulticastTtl gets the "multicast-ttl" property.
1871// Time-to-live out outgoing multicast packets
1872func (x *Socket) GetPropertyMulticastTtl() uint {
1873	var v gobject.Value
1874	x.GetProperty("multicast-ttl", &v)
1875	return v.GetUint()
1876}
1877
1878// SetPropertyTimeout sets the "timeout" property.
1879// The timeout in seconds on socket I/O
1880func (x *Socket) SetPropertyTimeout(value uint) {
1881	var v gobject.Value
1882	v.Init(gobject.TypeUintVal)
1883	v.SetUint(value)
1884	x.SetProperty("timeout", &v)
1885}
1886
1887// GetPropertyTimeout gets the "timeout" property.
1888// The timeout in seconds on socket I/O
1889func (x *Socket) GetPropertyTimeout() uint {
1890	var v gobject.Value
1891	x.GetProperty("timeout", &v)
1892	return v.GetUint()
1893}
1894
1895// SetPropertyTtl sets the "ttl" property.
1896// Time-to-live for outgoing unicast packets
1897func (x *Socket) SetPropertyTtl(value uint) {
1898	var v gobject.Value
1899	v.Init(gobject.TypeUintVal)
1900	v.SetUint(value)
1901	x.SetProperty("ttl", &v)
1902}
1903
1904// GetPropertyTtl gets the "ttl" property.
1905// Time-to-live for outgoing unicast packets
1906func (x *Socket) GetPropertyTtl() uint {
1907	var v gobject.Value
1908	x.GetProperty("ttl", &v)
1909	return v.GetUint()
1910}
1911
1912// Initializes the object implementing the interface.
1913//
1914// This method is intended for language bindings. If writing in C,
1915// g_initable_new() should typically be used instead.
1916//
1917// The object must be initialized before any real use after initial
1918// construction, either with this function or g_async_initable_init_async().
1919//
1920// Implementations may also support cancellation. If @cancellable is not %NULL,
1921// then initialization can be cancelled by triggering the cancellable object
1922// from another thread. If the operation was cancelled, the error
1923// %G_IO_ERROR_CANCELLED will be returned. If @cancellable is not %NULL and
1924// the object doesn't support cancellable initialization the error
1925// %G_IO_ERROR_NOT_SUPPORTED will be returned.
1926//
1927// If the object is not initialized, or initialization returns with an
1928// error, then all operations on the object except g_object_ref() and
1929// g_object_unref() are considered to be invalid, and have undefined
1930// behaviour. See the [description][iface@Gio.Initable#description] for more details.
1931//
1932// Callers should not assume that a class which implements #GInitable can be
1933// initialized multiple times, unless the class explicitly documents itself as
1934// supporting this. Generally, a class’ implementation of init() can assume
1935// (and assert) that it will only be called once. Previously, this documentation
1936// recommended all #GInitable implementations should be idempotent; that
1937// recommendation was relaxed in GLib 2.54.
1938//
1939// If a class explicitly supports being initialized multiple times, it is
1940// recommended that the method is idempotent: multiple calls with the same
1941// arguments should return the same results. Only the first call initializes
1942// the object; further calls return the result of the first call.
1943//
1944// One reason why a class might need to support idempotent initialization is if
1945// it is designed to be used via the singleton pattern, with a
1946// #GObjectClass.constructor that sometimes returns an existing instance.
1947// In this pattern, a caller would expect to be able to call g_initable_init()
1948// on the result of g_object_new(), regardless of whether it is in fact a new
1949// instance.
1950func (x *Socket) Init(CancellableVar *Cancellable) (bool, error) {
1951	var cerr *glib.Error
1952
1953	cret := XGInitableInit(x.GoPointer(), CancellableVar.GoPointer(), &cerr)
1954	if cerr == nil {
1955		return cret, nil
1956	}
1957	return cret, cerr
1958
1959}
1960
1961func init() {
1962	core.SetPackageName("GIO", "gio-2.0")
1963	core.SetSharedLibraries("GIO", []string{"libgio-2.0.so.0"})
1964	var libs []uintptr
1965	for _, libPath := range core.GetPaths("GIO") {
1966		lib, err := purego.Dlopen(libPath, purego.RTLD_NOW|purego.RTLD_GLOBAL)
1967		if err != nil {
1968			panic(err)
1969		}
1970		libs = append(libs, lib)
1971	}
1972
1973	core.PuregoSafeRegister(&xSocketGLibType, libs, "g_socket_get_type")
1974
1975	core.PuregoSafeRegister(&xNewSocket, libs, "g_socket_new")
1976	core.PuregoSafeRegister(&xNewSocketFromFd, libs, "g_socket_new_from_fd")
1977
1978	core.PuregoSafeRegister(&xSocketAccept, libs, "g_socket_accept")
1979	core.PuregoSafeRegister(&xSocketBind, libs, "g_socket_bind")
1980	core.PuregoSafeRegister(&xSocketCheckConnectResult, libs, "g_socket_check_connect_result")
1981	core.PuregoSafeRegister(&xSocketClose, libs, "g_socket_close")
1982	core.PuregoSafeRegister(&xSocketConditionCheck, libs, "g_socket_condition_check")
1983	core.PuregoSafeRegister(&xSocketConditionTimedWait, libs, "g_socket_condition_timed_wait")
1984	core.PuregoSafeRegister(&xSocketConditionWait, libs, "g_socket_condition_wait")
1985	core.PuregoSafeRegister(&xSocketConnect, libs, "g_socket_connect")
1986	core.PuregoSafeRegister(&xSocketConnectionFactoryCreateConnection, libs, "g_socket_connection_factory_create_connection")
1987	core.PuregoSafeRegister(&xSocketCreateSource, libs, "g_socket_create_source")
1988	core.PuregoSafeRegister(&xSocketGetAvailableBytes, libs, "g_socket_get_available_bytes")
1989	core.PuregoSafeRegister(&xSocketGetBlocking, libs, "g_socket_get_blocking")
1990	core.PuregoSafeRegister(&xSocketGetBroadcast, libs, "g_socket_get_broadcast")
1991	core.PuregoSafeRegister(&xSocketGetCredentials, libs, "g_socket_get_credentials")
1992	core.PuregoSafeRegister(&xSocketGetFamily, libs, "g_socket_get_family")
1993	core.PuregoSafeRegister(&xSocketGetFd, libs, "g_socket_get_fd")
1994	core.PuregoSafeRegister(&xSocketGetKeepalive, libs, "g_socket_get_keepalive")
1995	core.PuregoSafeRegister(&xSocketGetListenBacklog, libs, "g_socket_get_listen_backlog")
1996	core.PuregoSafeRegister(&xSocketGetLocalAddress, libs, "g_socket_get_local_address")
1997	core.PuregoSafeRegister(&xSocketGetMulticastLoopback, libs, "g_socket_get_multicast_loopback")
1998	core.PuregoSafeRegister(&xSocketGetMulticastTtl, libs, "g_socket_get_multicast_ttl")
1999	core.PuregoSafeRegister(&xSocketGetOption, libs, "g_socket_get_option")
2000	core.PuregoSafeRegister(&xSocketGetProtocol, libs, "g_socket_get_protocol")
2001	core.PuregoSafeRegister(&xSocketGetRemoteAddress, libs, "g_socket_get_remote_address")
2002	core.PuregoSafeRegister(&xSocketGetSocketType, libs, "g_socket_get_socket_type")
2003	core.PuregoSafeRegister(&xSocketGetTimeout, libs, "g_socket_get_timeout")
2004	core.PuregoSafeRegister(&xSocketGetTtl, libs, "g_socket_get_ttl")
2005	core.PuregoSafeRegister(&xSocketIsClosed, libs, "g_socket_is_closed")
2006	core.PuregoSafeRegister(&xSocketIsConnected, libs, "g_socket_is_connected")
2007	core.PuregoSafeRegister(&xSocketJoinMulticastGroup, libs, "g_socket_join_multicast_group")
2008	core.PuregoSafeRegister(&xSocketJoinMulticastGroupSsm, libs, "g_socket_join_multicast_group_ssm")
2009	core.PuregoSafeRegister(&xSocketLeaveMulticastGroup, libs, "g_socket_leave_multicast_group")
2010	core.PuregoSafeRegister(&xSocketLeaveMulticastGroupSsm, libs, "g_socket_leave_multicast_group_ssm")
2011	core.PuregoSafeRegister(&xSocketListen, libs, "g_socket_listen")
2012	core.PuregoSafeRegister(&xSocketReceive, libs, "g_socket_receive")
2013	core.PuregoSafeRegister(&xSocketReceiveBytes, libs, "g_socket_receive_bytes")
2014	core.PuregoSafeRegister(&xSocketReceiveBytesFrom, libs, "g_socket_receive_bytes_from")
2015	core.PuregoSafeRegister(&xSocketReceiveFrom, libs, "g_socket_receive_from")
2016	core.PuregoSafeRegister(&xSocketReceiveMessage, libs, "g_socket_receive_message")
2017	core.PuregoSafeRegister(&xSocketReceiveMessages, libs, "g_socket_receive_messages")
2018	core.PuregoSafeRegister(&xSocketReceiveWithBlocking, libs, "g_socket_receive_with_blocking")
2019	core.PuregoSafeRegister(&xSocketSend, libs, "g_socket_send")
2020	core.PuregoSafeRegister(&xSocketSendMessage, libs, "g_socket_send_message")
2021	core.PuregoSafeRegister(&xSocketSendMessageWithTimeout, libs, "g_socket_send_message_with_timeout")
2022	core.PuregoSafeRegister(&xSocketSendMessages, libs, "g_socket_send_messages")
2023	core.PuregoSafeRegister(&xSocketSendTo, libs, "g_socket_send_to")
2024	core.PuregoSafeRegister(&xSocketSendWithBlocking, libs, "g_socket_send_with_blocking")
2025	core.PuregoSafeRegister(&xSocketSetBlocking, libs, "g_socket_set_blocking")
2026	core.PuregoSafeRegister(&xSocketSetBroadcast, libs, "g_socket_set_broadcast")
2027	core.PuregoSafeRegister(&xSocketSetKeepalive, libs, "g_socket_set_keepalive")
2028	core.PuregoSafeRegister(&xSocketSetListenBacklog, libs, "g_socket_set_listen_backlog")
2029	core.PuregoSafeRegister(&xSocketSetMulticastLoopback, libs, "g_socket_set_multicast_loopback")
2030	core.PuregoSafeRegister(&xSocketSetMulticastTtl, libs, "g_socket_set_multicast_ttl")
2031	core.PuregoSafeRegister(&xSocketSetOption, libs, "g_socket_set_option")
2032	core.PuregoSafeRegister(&xSocketSetTimeout, libs, "g_socket_set_timeout")
2033	core.PuregoSafeRegister(&xSocketSetTtl, libs, "g_socket_set_ttl")
2034	core.PuregoSafeRegister(&xSocketShutdown, libs, "g_socket_shutdown")
2035	core.PuregoSafeRegister(&xSocketSpeaksIpv4, libs, "g_socket_speaks_ipv4")
2036
2037}

Keyboard shortcuts

Single-key shortcuts are on. ctrl k and esc work whatever this says.

ctrl k :
go to a section, branch, tag, file or repository
?
this list
j k
move the row cursor down / up
enter
open the row under the cursor; on Files, a directory opens or closes in place
↑ ↓ ← → home end
in the file tree (focus on a row): previous / next row, close / open a directory or go to its parent / first entry, first / last row. They never open a file
l h
on Files: open a directory or a file / close a directory or go up to its parent, then to the parent page. Elsewhere: into the side panel (on a merge request, its files) / back to the content; there j k move between its controls
g g G
first / last row
/
filter the list; on Files, find a file anywhere in the repository (esc clears, enter opens the best match)
b
switch branch or tag
g s g f g c g b g m g i g r g a
tabs: summary, files, commits, branches & tags, merge requests, issues, releases, actions (when available)
g h
home
w
wide mode: use the whole width of the screen, or not (remembered)
y
copy a permalink pinned to the commit
d u x
diff: split / unified / collapse or expand all
e E
diff: the whole file in view / every file, with the lines the hunks hide
n
merge request: next note in the diff
esc
close a dialog, leave a field

Branches 1

Tags 102

↑↓ moveenter openesc close