Skip to content

Commit

Permalink
Merge pull request #46 from vazir/write-func-update
Browse files Browse the repository at this point in the history
Remove redundant code in Write
  • Loading branch information
wmnsk authored May 1, 2023
2 parents dc75a35 + bc3ab65 commit fc509a5
Showing 1 changed file with 1 addition and 21 deletions.
22 changes: 1 addition & 21 deletions conn.go
Original file line number Diff line number Diff line change
Expand Up @@ -83,27 +83,7 @@ func (c *Conn) Read(b []byte) (n int, err error) {

// Write writes data to the connection.
func (c *Conn) Write(b []byte) (n int, err error) {
if c.state != StateAspActive {
return 0, ErrNotEstablished
}
d, err := messages.NewData(
c.cfg.NetworkAppearance, c.cfg.RoutingContexts, params.NewProtocolData(
c.cfg.OriginatingPointCode, c.cfg.DestinationPointCode,
c.cfg.ServiceIndicator, c.cfg.NetworkIndicator,
c.cfg.MessagePriority, c.cfg.SignalingLinkSelection, b,
), c.cfg.CorrelationID,
).MarshalBinary()
if err != nil {
return 0, err
}

n, err = c.sctpConn.SCTPWrite(d, c.sctpInfo)
if err != nil {
return 0, err
}

n += len(d)
return n, nil
return c.WriteToStream(b, c.sctpInfo.Stream)
}

// WriteToStream writes data to the connection and specific stream
Expand Down

0 comments on commit fc509a5

Please sign in to comment.