File tree Expand file tree Collapse file tree 3 files changed +33
-1
lines changed Expand file tree Collapse file tree 3 files changed +33
-1
lines changed Original file line number Diff line number Diff line change @@ -4,6 +4,11 @@ This file is a manually maintained list of changes for each release. Feel free
44to add your changes here when sending pull requests. Also send corrections if
55you spot any mistakes.
66
7+ ## 0.4.1 (2014-06-13)
8+
9+ * Fix: Uncaught Exception while processing ICMP rejection datagrams
10+ ([ #12 ] ( https://github.com/clue/datagram/pull/12 ) )
11+
712## 0.4.0 (2014-03-03)
813
914* BC break: Unified socket addresses (string URIs instead of host+port)
Original file line number Diff line number Diff line change 44
55use React \EventLoop \LoopInterface ;
66use Evenement \EventEmitter ;
7+ use Exception ;
78
89class Socket extends EventEmitter implements SocketInterface
910{
@@ -124,7 +125,7 @@ protected function handleReceive(&$peerAddress)
124125 // due to the nature of UDP, there's no way to tell which one exactly
125126 // $peer is not filled either
126127
127- throw new \ Exception ('Invalid message ' );
128+ throw new Exception ('Invalid message ' );
128129 }
129130
130131 $ peerAddress = $ this ->sanitizeAddress ($ peerAddress );
Original file line number Diff line number Diff line change @@ -87,6 +87,32 @@ public function testClientSendHugeWillFail()
8787 $ this ->loop ->run ();
8888 }
8989
90+ public function testClientSendNoServerWillFail ()
91+ {
92+ $ promise = $ this ->factory ->createClient ('127.0.0.1:1234 ' );
93+ $ client = $ this ->getValueFromResolvedPromise ($ promise );
94+
95+ // send a message to a socket that is not actually listening
96+ // expect the remote end to reject this by sending an ICMP message
97+ // which we will receive as an error message. This depends on the
98+ // host to actually reject UDP datagrams, which not all systems do.
99+ $ client ->send ('hello ' );
100+ $ client ->on ('error ' , $ this ->expectCallableOnce ());
101+
102+ $ loop = $ this ->loop ;
103+ $ client ->on ('error ' , function () use ($ loop ) {
104+ $ loop ->stop ();
105+ });
106+
107+ $ that = $ this ;
108+ $ this ->loop ->addTimer (1.0 , function () use ($ that , $ loop ) {
109+ $ loop ->stop ();
110+ $ that ->markTestSkipped ('UDP packet was not rejected after 0.5s, ignoring test ' );
111+ });
112+
113+ $ this ->loop ->run ();
114+ }
115+
90116 public function testCreatePair ()
91117 {
92118 $ promise = $ this ->factory ->createServer ('127.0.0.1:0 ' );
You can’t perform that action at this time.
0 commit comments