Re: [go-nuts] net.go ok function's c != nil check right ?

2020-06-03 Thread apmattil
ooh.. thanks.

On Wednesday, June 3, 2020 at 10:21:24 AM UTC+3, kortschak wrote:
>
> It's perfectly valid to call a method on a nil receiver, so long at the 
> nil receiver is not dereferenced. 
>
> https://play.golang.org/p/Z-zXlj0-eVy 
>
>
> On Wed, 2020-06-03 at 00:03 -0700, apma...@gmail.com  wrote: 
> > Read function at net.go is like this: 
> > 
> > func (c *conn) Read(b []byte) (int, error) { 
> > if !c.ok() { 
> > 
> > the ok checks that c is non nil: 
> > func (c *conn) ok() bool { return c != nil && c.fd != nil } 
> > 
> > how can c ever be nil ? if it would c.ok() call would crash. 
>
>
>
>

-- 
You received this message because you are subscribed to the Google Groups 
"golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to golang-nuts+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/golang-nuts/4ff204ac-7eda-4f08-a51e-24a177b95e3e%40googlegroups.com.


[go-nuts] net.go ok function's c != nil check right ?

2020-06-03 Thread apmattil
Read function at net.go is like this:

func (c *conn) Read(b []byte) (int, error) {
if !c.ok() {

the ok checks that c is non nil:
func (c *conn) ok() bool { return c != nil && c.fd != nil }

how can c ever be nil ? if it would c.ok() call would crash.

-- 
You received this message because you are subscribed to the Google Groups 
"golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to golang-nuts+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/golang-nuts/4969df86-c3ec-4b3f-916d-35a986884362%40googlegroups.com.


[go-nuts] how to convert or typecast windows handle/fd to net.conn

2018-12-04 Thread apmattil
Hi

My problem is following: I need to use windows WSAAccept() instead of 
normal accept (net package seems to use AcceptEx).

I'm I missing somethig 

I do not know a way to extend net-package so only way I know is to use 
reflect to get the listener Sysfd (I know .. really bad, other options ?) 
and pass it to WSAAccept().

Now I get the new handle/fd back and to be able to use rest of the code I 
would need to convert it to net.conn, how can I do this ?

In general, how can we extend net package when all important structures are 
private ? fd_windows.go:netFD struct includes poll.FD what is even deeper 
at package chain.

Br,
Ari

-- 
You received this message because you are subscribed to the Google Groups 
"golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to golang-nuts+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.