Git Product home page Git Product logo

Comments (6)

thinkgos avatar thinkgos commented on June 17, 2024

If add a return error on OnConnectHandler api?? if return error, indicate refuse the connection from server?? It seem like a idea.

from go-iecp5.

ecoshub avatar ecoshub commented on June 17, 2024

OnConnectionHandler does not implement a return error statement. Do you mean should I implement the return error statement to the source code ?

// SetOnConnectionHandler set on connect handler
func (sf *Server) SetOnConnectionHandler(f func(asdu.Connect)) {
	sf.onConnection = f
}

if I refuse connections by closing them client is attempting in a infinite loop.

mainServer = cs104.NewServer(&myServer{})
mainServer.SetOnConnectionHandler(func(asd asdu.Connect){
	asd.UnderlyingConn().Close()
})

from go-iecp5.

thinkgos avatar thinkgos commented on June 17, 2024

@ecoshub YES,OnConnectionHandler should implement a return error statement to the source code.

// SetOnConnectionHandler set on connect handler
func (sf *Server) SetOnConnectionHandler(f func(asdu.Connect) error ) {
	sf.onConnection = f
}

in the file server_session.go line 206 - 218

	defer func() {
		sf.setConnectStatus(disconnected)
		checkTicker.Stop()
		_ = sf.conn.Close() // 连锁引发cancel
		sf.wg.Wait()
		if sf.connectionLost != nil {
			sf.connectionLost(sf)
		}
		sf.Debug("run stopped!")
	}()

       if err := sf.onConnection(sf);err!= nil{
           return
      }

we can not forbid the client attempting in a infinite loop. only we can do, just refuse it.

what about this idea?

from go-iecp5.

ecoshub avatar ecoshub commented on June 17, 2024

Yes I am currently doing that without implementing any other code to the source code. I am just closing the connection with asdu.UnderlyingConn().Close(). That is not the case.

Let me rephrase the question. Does iec 60870-5 104 protocol has any ASDU command for closing the connection from server like client do with StopDT and does this package has any thing like that?

from go-iecp5.

thinkgos avatar thinkgos commented on June 17, 2024

sorry ,I can not find. you can refer to lib60870 c library lib60870 doc, maybe you can get an idea.

from go-iecp5.

ecoshub avatar ecoshub commented on June 17, 2024

Thank you so much for your help I will read doc again for an answer. If there is no answer for my question in the doc I will try to find out a solution and post it from here.

from go-iecp5.

Related Issues (14)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.