📄 reboot.cpp
字号:
/* $Id: reboot.cpp,v 1.1 2004/01/08 01:33:26 schrista Exp $ *//*** *** See the file "L2_RTI_EO1/disclaimers-and-notices-L2.txt" for *** information on usage and redistribution of this file, *** and for a DISCLAIMER OF ALL WARRANTIES. ***//* DESCRIPTION *//* The purpose of this "reboot" program is to send a TCP message to another * computer that has specially made hardware attached to it that will reboot * another computer -- in our case, a vxWorks PowerPC computer. * * To compile this program, type something like the following: * gcc -O2 -lsocket -lnsl reboot.cpp -o reboot *//* includes */#include <sys/types.h>#include <sys/socket.h>#include <arpa/inet.h>#include <stdio.h>#include <unistd.h>/*=========================================================================*\* FUNCTION* main** PURPOSE* The "main" starting place.** PARAMETERS* argc = The number of arguments that are being passed.* argv = An array of command line arguments.** RETURNS* 0 = okay* 1 = error\*=========================================================================*/int main(int argc, char **argv) { int Client, rClient; char *serverName; struct sockaddr_in saDest; int sockAddrSize = sizeof(struct sockaddr_in); if (argc == 2) { serverName = argv[1]; } else { /* Default to the computer that the PowerPC is attached to. */ serverName = "143.232.221.37"; } Client = socket(AF_INET, SOCK_STREAM, IPPROTO_TCP); if (Client == -1) { puts("Unable to open socket."); return 1; } /* Setup destination socket address. */ if ((saDest.sin_addr.s_addr = inet_addr(serverName)) == -1) { puts("Unknown server name."); } saDest.sin_family = AF_INET; saDest.sin_port = htons(6164); /* Port is Big Endian. */ /* Connect to target reboot server. */ rClient = connect(Client, (struct sockaddr*)(&saDest), sockAddrSize); if (rClient == -1) { puts("Unable to connect to host."); return 1; } send(Client, "sysReset", 8, 0); close(Client); return 0;}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -