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

SCTP Simple Mode Server failed to Close SCTPListener #4

Open
xp0inter opened this issue May 26, 2023 · 5 comments
Open

SCTP Simple Mode Server failed to Close SCTPListener #4

xp0inter opened this issue May 26, 2023 · 5 comments

Comments

@xp0inter
Copy link

xp0inter commented May 26, 2023

SCTP Simple Mode Server failed to Close SCTPListener if start AcceptSCTP but no request coming in.

	ln, err := sctp.ListenSCTP("sctp4",
		syscall.SOCK_STREAM,
		sctp_addr,
		&sctp.SCTPInitMsg{
			NumOutStreams:  0xffff,
			MaxInStreams:   0,
			MaxAttempts:    0,
			MaxInitTimeout: 0,
		},
	)
        if err != nil {
		...
	}
        defer ln.Close()
       
       // After  AcceptSCTP(), it will Block. If there is no request coming in ,
      // run ln.Close(), it won' work if the process not exists.
      // when I try to re-listen same port, it will show the address already been used.
       conn, err := ln.AcceptSCTP()  
       if err != nil {
       ...      
       }

Here is the example

image

After AcceptSCTP I run closed keep the process run...

image

image

Meanwhile I re-listen the same port , it shows Error: address already in use

image

Do you have any ideas about this problem? Thank you very much !

@thebagchi
Copy link
Owner

Investigating

@linouxis9
Copy link

linouxis9 commented Mar 14, 2024

Any updates / ideas? @thebagchi
@xp0inter Were you able to find a workaround?
Thanks a lot :-)

@thebagchi
Copy link
Owner

Reading through the kernel docs for close.
I understand calling close on a socket has no effect on active system calls on that socket, if they are being done on separate thread.
Refer:
http://www.kernel.org/doc/man-pages/online/pages/man2/close.2.html

@thebagchi
Copy link
Owner

Work around would be to use epoll.
Please refer to epoll example. It can be used for seq_packet as well.

@linouxis9
Copy link

Thanks a lot for the doc reference! @thebagchi

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

No branches or pull requests

3 participants