File tree 5 files changed +13
-26
lines changed
5 files changed +13
-26
lines changed Original file line number Diff line number Diff line change 56
56
// Check to make sure a command was actually supplied.
57
57
if (argc < 0 ) { printf ("Error: No command was supplied.\n" ); print_usage (); return -1 ; }
58
58
59
- #ifdef _WIN32
60
-
61
- // Startup network, under windows.
62
- if (network_startup () < 0 ) { printf ("Error: Could not start up winsock.\n" ); return 1 ; }
63
-
64
- #endif
59
+ // Startup network
60
+ if (network_startup () < 0 ) { printf ("Error: Could not startup network.\n" ); return 1 ; }
65
61
66
62
// Connect to the ps2netfs server.
67
63
if (ps2netfs_connect (hostname ) < 0 ) { printf ("Error: Could not connect to the ps2netfs server. (%s)\n" , hostname ); return -1 ; }
Original file line number Diff line number Diff line change 13
13
// NETWORK FUNCTIONS //
14
14
///////////////////////
15
15
16
- #ifdef _WIN32
17
16
int network_startup (void ) {
17
+ #ifdef _WIN32
18
18
WSADATA wsaData ;
19
19
20
20
// Start up winsock.
21
21
if (WSAStartup (MAKEWORD (2 , 0 ), & wsaData ) != 0 ) { return -1 ; }
22
22
23
+ #endif
23
24
// End function.
24
25
return 0 ;
25
-
26
26
}
27
- #endif
28
27
29
28
int network_connect (char * hostname , int port , int type ) { int sock = -1 ;
30
29
struct sockaddr_in sockaddr ;
Original file line number Diff line number Diff line change 12
12
// NETWORK FUNCTIONS //
13
13
///////////////////////
14
14
15
- #ifdef _WIN32
16
15
int network_startup (void );
17
- #endif
18
16
19
17
int network_connect (char * hostname , int port , int type );
20
18
Original file line number Diff line number Diff line change 5
5
#include <unistd.h>
6
6
#include "utility.h"
7
7
#include "ps2link.h"
8
- #ifdef _WIN32
9
8
#include "network.h"
10
- #endif
11
9
12
10
char hostname [256 ] = { "192.168.0.10" };
13
11
65
63
// Check to make sure a command was actually supplied.
66
64
if (argc < 0 ) { printf ("Error: No command was supplied.\n" ); print_usage (); return -1 ; }
67
65
68
- #ifdef _WIN32
69
-
70
- // Startup network, under windows.
71
- if (network_startup () < 0 ) { printf ("Error: Could not start up winsock.\n" ); return 1 ; }
72
-
73
- #endif
66
+ // Startup network.
67
+ if (network_startup () < 0 ) { printf ("Error: Could not startup network.\n" ); return 1 ; }
74
68
75
69
// Connect to the ps2link server.
76
70
if (ps2link_connect (hostname ) < 0 ) { printf ("Error: Could not connect to the ps2link server. (%s)\n" , hostname ); return -1 ; }
Original file line number Diff line number Diff line change 13
13
#else
14
14
#include <windows.h>
15
15
#define sleep (x ) Sleep(x * 1000)
16
+ #define pause () while (1) { Sleep(600000); }
16
17
#endif
17
18
18
19
#include "network.h"
59
60
command_socket = network_connect (hostname , 0x4712 , SOCK_DGRAM );
60
61
61
62
// Delay for a moment to let ps2link finish setup.
62
- #ifdef _WIN32
63
- Sleep (1 );
64
- #else
65
63
sleep (1 );
66
- #endif
67
64
68
65
// End function.
69
66
return 0 ;
78
75
// If no timeout was given, timeout immediately.
79
76
if (timeout == 0 ) { return 0 ; }
80
77
81
- // If timeout was never, loop forever.
82
- if (timeout < 0 ) { for (;;) { sleep ( 600 ); } }
78
+ // If timeout was never, wait forever.
79
+ if (timeout < 0 ) { pause (); }
83
80
84
81
// Increment the timeout counter until timeout is reached.
85
82
while (ps2link_counter ++ < timeout ) { sleep (1 ); };
90
87
}
91
88
92
89
int ps2link_disconnect (void ) {
93
-
90
+ // Kill created threads.
91
+ pthread_cancel (request_thread_id );
92
+ pthread_cancel (console_thread_id );
93
+
94
94
// Disconnect from the command port.
95
95
if (network_disconnect (command_socket ) < 0 ) { return -1 ; }
96
96
You can’t perform that action at this time.
0 commit comments