Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

What are the four methods actually used by Java XMLSocket?

2025-01-16 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)06/03 Report--

What are the four methods actually used by Java XMLSocket? I believe many inexperienced people are at a loss about this. Therefore, this paper summarizes the causes and solutions of the problem. Through this article, I hope you can solve this problem.

ActionScript 3.0 provides a way to communicate with the server side over a Java XMLSocket connection. This is an important feature that goes beyond the traditional Bhand S structure. In this way, the network communication can be connected immediately, which avoids the disadvantage of stateless connection of HTTP protocol. ActionScript 3.0 uses the Java XMLSocket class to connect. It is important to note that when you use the XMLSocket class for Socket connections, you cannot automatically traverse the firewall. To connect through a firewall, you need to use the RTMP protocol based on the HTTP protocol.

By referring to the API documentation provided by Adobe, you can see that Java XMLSocket provides four public methods:

1. Java XMLSocket (host:String=null,port:int=0)-- create a new XMLSocket object.

2. Close (): void-- closes a XMLSocket.

3. Connect (host:String,port:int): void-- connects to the specified TCP port.

4. Send (object:*): void-- sends data to the connection server.

OK, after knowing these, we can use XMLSocket to develop network and timely communication applications based on Java XMLSocket. The following provides a Socket server through C# and listens to port 8888. The example program is as follows:

Using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Net.Sockets; using System.IO; namespace FlashFlexDotNet {class Program {static void Main (string [] args) {TcpListener listener; try {listener = new TcpListener (8888);} catch (Exception ex) {Console.WriteLine (ex.Message); return;} listener.Start (); Console.WriteLine ("Server starts, waiting for client connection.") Bool loop = true; while (loop) {Socket s = listener.AcceptSocket (); NetworkStream ns = new NetworkStream (s); StreamReader reader = new StreamReader (ns); string result = string.Empty; try {result = reader.ReadLine (); Console.WriteLine (result);} catch (Exception ex) {Console.WriteLine (ex.Message) } after reading the above, have you mastered what are the four methods actually used by Java XMLSocket? If you want to learn more skills or want to know more about it, you are welcome to follow the industry information channel, thank you for reading!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report