File tree Expand file tree Collapse file tree 1 file changed +5
-2
lines changed Expand file tree Collapse file tree 1 file changed +5
-2
lines changed Original file line number Diff line number Diff line change 9
9
$ srvsock = stream_socket_server ("tcp:// {$ ipaddr }: {$ port }" );
10
10
if (!$ srvsock ) { die (); }
11
11
$ s = stream_socket_accept ($ srvsock , -1 );
12
+ fclose ($ srvsock );
12
13
$ s_type = 'stream ' ;
13
14
} elseif (is_callable ('socket_create_listen ' )) {
14
15
$ srvsock = socket_create_listen (AF_INET , SOCK_STREAM , SOL_TCP );
15
16
if (!$ res ) { die (); }
16
17
$ s = socket_accept ($ srvsock );
18
+ socket_close ($ srvsock );
17
19
$ s_type = 'socket ' ;
18
20
} elseif (is_callable ('socket_create ' )) {
19
21
$ srvsock = socket_create (AF_INET , SOCK_STREAM , SOL_TCP );
20
22
$ res = socket_bind ($ srvsock , $ ipaddr , $ port );
21
23
if (!$ res ) { die (); }
22
24
$ s = socket_accept ($ srvsock );
25
+ socket_close ($ srvsock );
23
26
$ s_type = 'socket ' ;
24
27
} else {
25
28
die ();
26
29
}
27
30
if (!$ s ) { die (); }
28
31
29
- switch ($ s_type ) {
32
+ switch ($ s_type ) {
30
33
case 'stream ' : $ len = fread ($ s , 4 ); break ;
31
34
case 'socket ' : $ len = socket_read ($ s , 4 ); break ;
32
35
}
40
43
41
44
$ b = '' ;
42
45
while (strlen ($ b ) < $ len ) {
43
- switch ($ s_type ) {
46
+ switch ($ s_type ) {
44
47
case 'stream ' : $ b .= fread ($ s , $ len -strlen ($ b )); break ;
45
48
case 'socket ' : $ b .= socket_read ($ s , $ len -strlen ($ b )); break ;
46
49
}
You can’t perform that action at this time.
0 commit comments