导航:首页 > 配服务器 > 如何截获服务器socket数据

如何截获服务器socket数据

发布时间:2023-08-25 05:47:36

java socket服务器如何捕获并释放无效连接

这个很简单啊。设置超时就可以了,当超过一定时间没有进行数据交换的话,会自动关闭的。或者写个监护线程,查看状态。socket还有一个方法叫isClose也可以进行判断。楼下的是sice5921:是2货来到的,来混分的楼主千万别给分他,像这种拉基进来一次检举一次,哪怕把问题关闭了也不给这种拉基分

㈡ 网络中如何截取数据包修改后返回服务器

截取数据包可以仿照sniffer的方法,将把网卡置于混杂模式(Raw Socket)的方法,然后抓包,分析……
另外你的网络流量监控系统是监控链路还是监控节点,监控节点的话直接访问注册表就可以了(windows),如果是监控整个网络环境的话可参考icmp协议的使用。

android socket 接收服务器返回数据,如何查找想要的数值

Android 客户端代码:

package com.ltb.SCActivity;

import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.OutputStreamWriter;
import java.io.PrintWriter;
import java.net.Socket;

import android.app.Activity;
import android.os.Bundle;
import android.os.Handler;
import android.os.Message;
import android.util.Log;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.EditText;
import android.widget.TextView;

public class SCActivity extends Activity {
private TextView mRecvText = null;
private EditText mSentText = null;
private Button mSendRecvButton = null;
private Socket mSocket = null;

/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);

mRecvText = (TextView)findViewById(R.id.recvText);
mSentText = (EditText)findViewById(R.id.sentText);
mSendRecvButton = (Button)findViewById(R.id.sendRecvButton);

mSendRecvButton.setOnClickListener(new OnClickListener() {

@Override
public void onClick(View v) {

String sentMessage = mSentText.getText().toString() + "\r\n";

try {
mSocket = new Socket("10.126.38.155", 12577);

Log.i("------SCActivity---before send---", sentMessage);

PrintWriter send = new PrintWriter(new BufferedWriter(new OutputStreamWriter(mSocket.getOutputStream())));
send.println(sentMessage);
send.flush(); //Important!!!!!!
//send.write(sentMessage);
Log.i("------SCActivity---after send---", sentMessage);

BufferedReader recv = new BufferedReader(new InputStreamReader(mSocket.getInputStream()));
Log.i("------SCActivity---Before ---recv.readLine()---", sentMessage);
String recvMsg = recv.readLine();
Log.i("------SCActivity---after ---recv.readLine()---", recvMsg);
if (recvMsg != null) {
mRecvText.setText(recvMsg);
} else {
mRecvText.setText("Cannot receive data correctly.");
}

send.close();
recv.close();
mSocket.close();
} catch (Exception ex) {
ex.printStackTrace();
}
}
});
}

服务器端代码:
import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.InputStreamReader;
import java.io.OutputStreamWriter;
import java.io.PrintWriter;
import java.net.ServerSocket;
import java.net.Socket;

public class Server implements Runnable {
public void run() {
try {
ServerSocket serverSocket = new ServerSocket(12577);
while (true) {
Socket client = serverSocket.accept();
System.out.println("accept");
try {
BufferedReader in = new BufferedReader(new InputStreamReader(client.getInputStream()));
String str = in.readLine();
System.out.println("read:" + str);
PrintWriter pout = new PrintWriter(new BufferedWriter(new OutputStreamWriter(client.getOutputStream())), true);
//pout.write("Server Received Message: " + str);
pout.println("Server Received Message: " + str);

System.out.println("after send in server");
/* BufferedReader in = new BufferedReader(new InputStreamReader(client.getInputStream()));
String str = in.readLine();
System.out.println("read:" + str);*/

pout.close();
in.close();
} catch (Exception e) {
System.out.println(e.getMessage());
e.printStackTrace();
} finally {
client.close();
System.out.println("close");
}
}
} catch (Exception e) {
System.out.println(e.getMessage());
}
}

public static void main(String argv[] ) {
Thread pcServerThread = new Thread(new Server());
pcServerThread.start();
}
}

阅读全文

与如何截获服务器socket数据相关的资料

热点内容
华为加密壁纸怎么提取 浏览:52
曲线命令的描述 浏览:454
php模板怎么修改 浏览:999
单片机和微机编程的区别 浏览:642
金牛期货哪个app好 浏览:803
程序员越老越贬值吗 浏览:211
安卓手机用计算机如何隐藏应用 浏览:459
网吧服务器如何架设 浏览:322
垃圾压缩罐用电安全 浏览:621
b150能用什么服务器cpu 浏览:477
支付宝批量付款app哪个好 浏览:849
java开源社区源码 浏览:475
cad哪个命令和滚轮一样缩放 浏览:986
5日金叉10均量线选股公式源码 浏览:593
文件夹有竖线怎么去 浏览:1002
如何连接服务器并实现同步 浏览:332
androidseekbar进度条 浏览:358
梯度上升算法知乎 浏览:652
qt项目源码下载 浏览:395
不允许代理服务器什么意思 浏览:513