Skip to content

Commit

Permalink
Add unshift() to Socket
Browse files Browse the repository at this point in the history
  • Loading branch information
trowski committed Dec 21, 2015
1 parent ebf5ec3 commit e45c7e7
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 3 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# Changelog

## [0.5.2] - 2015-12-21
### Added
- Added an `unshift()` method to `Icicle\Socket\Socket` that shifts data back to the front of the stream. The data will be the first data read from any pending on subsequent read.

## [0.5.1] - 2015-12-20
### Changed
- Simultaneous reads are now allowed on `Icicle\Socket\Datagram\BasicDatagram` and simultaneous accepts are allowed on `Icicle\Socket\Server\BasicServer`, fulfilling in the order they were created. Simultaneous reads/accepts will not fulfill with the same data, rather each is fulfilled independently with new data read from the stream or new client accepted on the server.
Expand Down Expand Up @@ -56,6 +60,7 @@
- Initial release after split from the main [Icicle repository](https://github.com/icicleio/icicle).


[0.5.2]: https://github.com/icicleio/socket/releases/tag/v0.5.2
[0.5.1]: https://github.com/icicleio/socket/releases/tag/v0.5.1
[0.5.0]: https://github.com/icicleio/socket/releases/tag/v0.5.0
[0.4.1]: https://github.com/icicleio/socket/releases/tag/v0.4.1
Expand Down
22 changes: 22 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,8 @@ Loop\run();
- [Socket](#socket)
- [NetworkSocket Constructor](#networksocket-constructor) - Creates a socket object from a stream socket resource.
- [enableCrypto()](#enablecrypto) - Enables crypto on the socket.
- [isCryptoEnabled()](#iscryptoenabled) - Determines if crypto is enabled on the socket.
- [unshift()](#unshift) - Shifts data back to the front of the socket stream.
- [getLocalAddress()](#getlocaladdress) - Returns the local address of the socket.
- [getLocalPort()](#getlocalport) - Returns the local port of the socket.
- [getRemoteAddress()](#getremoteaddress) - Returns the remote address of the socket.
Expand Down Expand Up @@ -225,6 +227,26 @@ Enables encryption on the socket. For Socket objects created from `Icicle\Socket

---

#### isCryptoEnabled()

```php
Socket::isCryptoEnabled(): bool
```

Determines if encryption is enabled on the socket.

---

#### unshift()

```php
Socket::unshift(string $data): void
```

Determines if encryption is enabled on the socket.

---

#### getLocalAddress()

```php
Expand Down
13 changes: 10 additions & 3 deletions src/Socket.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,8 @@ interface Socket extends DuplexStream, Resource
*
* @resolve null
*
* @throws \Icicle\Socket\Exception\BusyError If the client was already busy waiting to read.
* @throws \Icicle\Socket\Exception\FailureException If enabling crypto fails.
* @throws \Icicle\Socket\Exception\ClosedException If the client has been closed.
* @throws \Icicle\Stream\Exception\ClosedException If the socket has been closed.
*/
public function enableCrypto($method, $timeout = 0);

Expand All @@ -37,7 +36,15 @@ public function enableCrypto($method, $timeout = 0);
* @return bool
*/
public function isCryptoEnabled();


/**
* Shifts the given data back to the front of the socket stream. The data will be the first bytes returned from any
* pending or subsequent read.
*
* @param string $data
*/
public function unshift($data);

/**
* Returns the remote IP or socket path as a string representation.
*
Expand Down

0 comments on commit e45c7e7

Please sign in to comment.