Git Product home page Git Product logo

Comments (5)

hilaolu avatar hilaolu commented on July 17, 2024

Wired Character in Java socket output stream

import java.net.ServerSocket;
import java.net.Socket;
import java.io.ObjectOutputStream;
import java.io.PrintStream;
import java.io.DataOutputStream;

public class Server {
	public static void main(String[] args) {
		try {

			ServerSocket server_socket = new ServerSocket(11451);
			Socket client_socket = server_socket.accept();
			PrintStream print_output_stream = new PrintStream(new ObjectOutputStream(client_socket.getOutputStream()));
			while (true) {
				print_output_stream.println("hello world");
				print_output_stream.flush();
				Thread.sleep(1145);
			}
		} catch (Exception e) {
			// do nothing
		}
	}
}

telnet 127.0.0.1 11451
Trying 127.0.0.1...
Connected to 127.0.0.1.
Escape character is '^]'.
��w
   hello world
w
 hello world
w
 hello world
w
 hello world
w
 hello world

Solution by @Origami404
Just remove ObjectOutputStream

PrintStream print_output_stream = new PrintStream((client_socket.getOutputStream());

from weekly.

hilaolu avatar hilaolu commented on July 17, 2024

Auto type inferring in java

from weekly.

hilaolu avatar hilaolu commented on July 17, 2024

音乐推荐:

滚啊滚啊 Archlinux

from weekly.

eastonman avatar eastonman commented on July 17, 2024

from weekly.

Origami404 avatar Origami404 commented on July 17, 2024

QQ图片20220516215133
QQ图片20220516215136
QQ图片20220516215145
QQ图片20220516215148
QQ图片20220516215154
QQ图片20220516215204
QQ图片20220516215209
QQ图片20220516104816
QQ图片20220516113331
QQ图片20220516113335
QQ图片20220516113405

from weekly.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.