TCP Connection
The foundation of TCP is Socket. In the TCP connection, we will use ServerSocket and Socket. After the client and server establish a connection, the rest is basically the control of I/O.
Let's first look at a simple TCP communication, which is divided into the client and the server.
The client code is as follows:
Copy codeThe Code is as follows: a simple TCP client
Import java.net .*;
Import java. io .*;
Public class SimpleTcpClient {
Public static void main (String [] args) thro
the default order in the 10th chapter. Views that open and close on individual content items provide absolute control over which items are accepted. You can also set whether to accept comments at the content type level, and each meaning content item is created by using that content type to "inherit" the setting. I will set the global parameters, such as accepting comments, in the 10th chapter.URL Path SettingsYou may have noticed that at the same time with the revision work is characterized by
. getinputstream ();// Read from the stream.Is. Close ();S. Close ();
Next, we will demonstrate a customer program of a stream socket. This program will create a socket object and the socket will access the service program running on the specified host port 10000, if the access is successful, the client program will send a series of commands to the service program and print the response of the service program. List2 let us create the program ssclient source code:
Listing 2: ssclient. Java
/*gino -/7/Ten +: the: -*/#include #include #include #include #include intMain () {/* The GetLogin function returns the logon name associated with the current user. The Getuid function returns the UID associated with the program, which is usually the UID of the user who initiates the program. */ printf("Login user is %s\ n",GetLogin());printf("uid=%d, gid=%d\ n", Getuid (), Getgid ());/ * System files/etc/PASSWD contains a database of user accounts. It consists of rows with one user pe
(); System. out. println ("ip:" + ip); // get the socket to read the stream and decorate BufferedReader br = new BufferedReader (new InputStreamReader (socket. getInputStream (); // get the socket output stream and decorate PrintWriter pw = new PrintWriter (socket. getOutputStream (), true); // new PrintWriter (socket. outputtream () String line = null; while (line = br. readLine ())! = Null) {System. out. println (line);
Beginner script + ajax data submission question HTML content
............
Password: ">
Email: ">
............
Script
Function submit (I)
{
Var sendData = "";
If (I = "1") {sendData = '{"action": "' + I + '", "pw":' + getElementByName + ', "email ": '+ getElementByName + ':}';}
$. Ajax ({
Timeout: 5000,
Type: "POST ",
Url: "edit_server.php ",
Data: sendData,
Success: function (data)
{
GetData (1); // This is a function used to open a page
1Chcp650012 SetHome_dir=Kp_home3 Setpackage_dir=/root/Java_source4 SetConfig_home=Anydir5 Setresource_path=/home/frank/opensource6 SetExchange_dir=\exchange.90km.com\Exchange7 Setremote_host=192.168.80.848 SetLogin_user=Root9 SetRemote_passwd=123456Ten One REM1. Create a working directory A ifexist%home_dir% ( -RD/S/Q%home_dir% - ) the MD%home_dir% - REM2. Enter the working directory - CD%home_dir% - + REM3. Get the PSCP tool. -xcopy \%exchange_dir%\xf\Pscp.exe + A REM4. Use PSCP to download
, it is time to exchange files or execute remote commands. this can be done by using 2 small CommandLine utilities called pscp for file transfer and plink for executing remote commands such as remotely deleting files etc. make sure these are in you path settings so you can execute them everywhere!
Examples for executing a remote command (substitute the % parameters % with your own ones)
'create a directory' plink -batch -pw %PASSWORD% %USERNAME%@%HOST
not ' enter the password? '); Return Self.inputext=self.texti.get (1.0,TK. END) If self.inputext== ': Tk.messagebox.showinfo (' Error ', ' What's your inputext? '); return if Self.inpuText[0].isdigit (): If not Tk.messagebox.askyesno (' Note ', ' is you sure is encrypting digits? '): Return Self.__encrypt () def __crack (self): "indicates that the input text should is number only" Self.texto.delete (1.0,TK. END) listp=list (SELF.PASSW) P=[ord (x) for x in LISTP]
The backend receives data through $name=i (' name ') and $pw=i (' PW ') after submission but Echo comes out and shows the undefined why? The return is also always 0, is the AJAX part of the code wrong? But F12 was right when he checked.
public function ajax(){ $user=M('user'); $name=I('name'); $pw=I('
{Public static void main (string [] ARGs) throws ioexception{System. Out. println ("server starting.../N ");// Create a server socket that listens for incoming connection// Requests on port 10000.Serversocket Server = new serversocket (10000 );While (true){// Listen for incoming connection requests from client// Programs, establish a connection, and return a socket// Object that represents this connection.Socket S = server. Accept ();System. Out. println ("accepting connection.../N ");// Start a
\system32\notepad. EXE ', ' d:/1.txt '}, attr)Fmt. PRINTLN (P)If err: = p.signal (OS. Kill); Err! = Nil {//Send a signal to the system to kill him so our familiar notepad won't come out.Fmt. PRINTLN (ERR)}}
[/php]
[6]func (P *process) Wait () (*processstate, error) as soon as you see, this function is waiting for the function of the process to complete, and then return the process struct body pointer to the
[PHP]Import ("FMT""OS")
Func Main () {attr: = os. procattr{Files: []*os. File{os. Stdin,
Please help me !!!The problem is: when the client calls WebService, The called method is continuously executed. When a print statement is added, aaaaaaaaaaaaa is continuously printed and called.Code: List = client. getalluser ();The following code is used:
Service Interface:Package com. Zhang. interfaces;
Import java. util. List;
Import com. SMC. entity. userinfo;
Public interface userservice {
Public userservice getuser (string userid );
Public list
Public String getuserid ();Pub
thing is to verify the user name and password, and then you can add the verification code and not log on at the same time to verify whether it is in the background blacklist.You can also limit the number of wrong user names or passwords entered by users. if there are too many errors, you will be unable to log on to the system for a certain period of time. In fact, there are still a lot of things that can be added to the login function ..
Do not use SQL injection.
SELECT count(*) FROM user WHE
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.