Write will Flush soon.
(p []byte)
| 336 | |
| 337 | // Write will Flush soon. |
| 338 | func (c *connection) Write(p []byte) (n int, err error) { |
| 339 | if !c.IsActive() { |
| 340 | return 0, Exception(ErrConnClosed, "when write") |
| 341 | } |
| 342 | |
| 343 | if !c.lock(flushing) { |
| 344 | return 0, Exception(ErrConcurrentAccess, "when write") |
| 345 | } |
| 346 | defer c.unlock(flushing) |
| 347 | |
| 348 | dst, _ := c.outputBuffer.Malloc(len(p)) |
| 349 | n = copy(dst, p) |
| 350 | c.outputBuffer.Flush() |
| 351 | err = c.flush() |
| 352 | return n, err |
| 353 | } |
| 354 | |
| 355 | // Close implements Connection. |
| 356 | func (c *connection) Close() error { |