File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 5656 // Check to make sure a command was actually supplied.
5757 if (argc < 0 ) { printf ("Error: No command was supplied.\n" ); print_usage (); return -1 ; }
5858
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 ; }
6561
6662 // Connect to the ps2netfs server.
6763 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 1313 // NETWORK FUNCTIONS //
1414 ///////////////////////
1515
16- #ifdef _WIN32
1716 int network_startup (void ) {
17+ #ifdef _WIN32
1818 WSADATA wsaData ;
1919
2020 // Start up winsock.
2121 if (WSAStartup (MAKEWORD (2 , 0 ), & wsaData ) != 0 ) { return -1 ; }
2222
23+ #endif
2324 // End function.
2425 return 0 ;
25-
2626 }
27- #endif
2827
2928 int network_connect (char * hostname , int port , int type ) { int sock = -1 ;
3029 struct sockaddr_in sockaddr ;
Original file line number Diff line number Diff line change 1212 // NETWORK FUNCTIONS //
1313 ///////////////////////
1414
15- #ifdef _WIN32
1615 int network_startup (void );
17- #endif
1816
1917 int network_connect (char * hostname , int port , int type );
2018
Original file line number Diff line number Diff line change 55 #include <unistd.h>
66 #include "utility.h"
77 #include "ps2link.h"
8- #ifdef _WIN32
98 #include "network.h"
10- #endif
119
1210 char hostname [256 ] = { "192.168.0.10" };
1311
6563 // Check to make sure a command was actually supplied.
6664 if (argc < 0 ) { printf ("Error: No command was supplied.\n" ); print_usage (); return -1 ; }
6765
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 ; }
7468
7569 // Connect to the ps2link server.
7670 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 1313#else
1414 #include <windows.h>
1515 #define sleep (x ) Sleep(x * 1000)
16+ #define pause () while (1) { Sleep(600000); }
1617#endif
1718
1819 #include "network.h"
5960 command_socket = network_connect (hostname , 0x4712 , SOCK_DGRAM );
6061
6162 // Delay for a moment to let ps2link finish setup.
62- #ifdef _WIN32
63- Sleep (1 );
64- #else
6563 sleep (1 );
66- #endif
6764
6865 // End function.
6966 return 0 ;
7875 // If no timeout was given, timeout immediately.
7976 if (timeout == 0 ) { return 0 ; }
8077
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 (); }
8380
8481 // Increment the timeout counter until timeout is reached.
8582 while (ps2link_counter ++ < timeout ) { sleep (1 ); };
9087 }
9188
9289 int ps2link_disconnect (void ) {
93-
90+ // Kill created threads.
91+ pthread_cancel (request_thread_id );
92+ pthread_cancel (console_thread_id );
93+
9494 // Disconnect from the command port.
9595 if (network_disconnect (command_socket ) < 0 ) { return -1 ; }
9696
You can’t perform that action at this time.
0 commit comments