Jump to content

Recommended Posts

Posted

Wouldn't it be better with sockets? I used to face problems trading datagram packets between machines who belong to different networks.

choose DatagramSockets because Sockets had a limitation in connection(only 1 client can connect)  because of  streams 

Posted

choose DatagramSockets because Sockets had a limitation in connection(only 1 client can connect)  because of  streams 

 

In combination with threads you can connect to multiple clients. But, in this occasions, it seems that Datagrams are fine, by the time packet order doesn't matter.

 

Also, you propably forgot to send the online data back to the client, at the online command.

Posted

In combination with threads you can connect to multiple clients. But, in this occasions, it seems that Datagrams are fine, by the time packet order doesn't matter.

I was afraid of packet loss/order but most of people going to use it through localhost and if machine I think machine have connection speed enough to send and recieve data without any problems.

 

Also, you propably forgot to send the online data back to the client, at the online command.

updated thanks

Posted

U guys suck at channels and threading.

 

Datagram = (unreliable connection - that's its naming, but its a good thing!) simple minded. Connection - W <-> R, end; Perfect for telnets. Or command servers.

TCP = (Transport Protocol) bad for such a thing, you need to maintain a connection, that is always vulnerable.

 

You guys should check out SocketChannels and Datagram channels in the nio package.

 

Edit: Dat http://docs.oracle.com/javase/7/docs/api/java/nio/channels/package-summary.html

Posted

Also, you MUST add some more server-side checks about the password, because in that way if someone codes his own gui, which doesn't ask for a password, he would be able to send commands normally.

 

A good idea is that after password check, the server should accept packets only by the approved ip address.

Posted

Also, you MUST add some more server-side checks about the password, because in that way if someone codes his own gui, which doesn't ask for a password, he would be able to send commands normally.

 

A good idea is that after password check, the server should accept packets only by the approved ip address.

Just a boolean in server-side code.

Posted

Sorry, for keep messing with this one, but you reminded me to add a telnet system to pes, and while I was working on it I also realised that your client is not working too. But, the sample client that I coded worked fine.

 

telnet

 

package com.pauler;

import java.io.IOException;
import java.net.DatagramPacket;
import java.net.DatagramSocket;
import java.net.InetAddress;
import java.net.SocketException;
import java.net.UnknownHostException;

public class TelnetClient {

DatagramSocket socket;

public TelnetClient() {
	while (true) {
		try {
			socket = new DatagramSocket();
		} catch (SocketException e1) {
			// TODO Auto-generated catch block
			e1.printStackTrace();
		}

		try {
			sendData("wswsws".getBytes(), InetAddress.getByName("127.0.0.1"), 1234);
		} catch (UnknownHostException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}

		try {
			Thread.sleep(3000);
		} catch (InterruptedException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
	}
}

public static void main(String[] args) {
	getInstance();
}

public static TelnetClient getInstance() {
	return SingletonHandler._instance;
}

public void sendData(byte[] data, InetAddress ipAddress, int packetPort)
{
	DatagramPacket packet = new DatagramPacket(data, data.length, ipAddress, packetPort);
	try
	{
		socket.send(packet);
	}
	catch (IOException e)
	{
		e.printStackTrace();
	}
	System.out.println("sent : " + new String(data));
}

private static class SingletonHandler {
	protected static final TelnetClient _instance = new TelnetClient();
}
}

 

 

Posted

Sorry, for keep messing with this one, but you reminded me to add a telnet system to pes, and while I was working on it I also realised that your client is not working too. But, the sample client that I coded worked fine.

 

telnet

 

package com.pauler;

import java.io.IOException;
import java.net.DatagramPacket;
import java.net.DatagramSocket;
import java.net.InetAddress;
import java.net.SocketException;
import java.net.UnknownHostException;

public class TelnetClient {

DatagramSocket socket;

public TelnetClient() {
	while (true) {
		try {
			socket = new DatagramSocket();
		} catch (SocketException e1) {
			// TODO Auto-generated catch block
			e1.printStackTrace();
		}

		try {
			sendData("wswsws".getBytes(), InetAddress.getByName("127.0.0.1"), 1234);
		} catch (UnknownHostException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}

		try {
			Thread.sleep(3000);
		} catch (InterruptedException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
	}
}

public static void main(String[] args) {
	getInstance();
}

public static TelnetClient getInstance() {
	return SingletonHandler._instance;
}

public void sendData(byte[] data, InetAddress ipAddress, int packetPort)
{
	DatagramPacket packet = new DatagramPacket(data, data.length, ipAddress, packetPort);
	try
	{
		socket.send(packet);
	}
	catch (IOException e)
	{
		e.printStackTrace();
	}
	System.out.println("sent : " + new String(data));
}

private static class SingletonHandler {
	protected static final TelnetClient _instance = new TelnetClient();
}
}

 

 

Damn, forgot to add port when you connect . im fking idiot

so the jar was sending to other port this is why the server didn't respond.

Updated the jar

bq8s.png

download : http://www.4shared.com/file/jMwT12D0/Telnet.html

code : http://pastebin.com/gcH4J8Xz

 

Also added a boolean check if connected to be more secured

 

really sorry i dont know how i forgot to add the port

 

Posted

Damn, forgot to add port when you connect . im fking idiot

so the jar was sending to other port this is why the server didn't respond.

Updated the jar

bq8s.png

download : http://www.4shared.com/file/jMwT12D0/Telnet.html

code : http://pastebin.com/gcH4J8Xz

 

Also added a boolean check if connected to be more secured

 

really sorry i dont know how i forgot to add the port

 

Again, it is not secured. Once it gets to true, everyone would be able to connect by a custom client.
Guest
This topic is now closed to further replies.


  • Posts

    • I've purchased the Samurai interface. Everything went smoothly, and the interface is excellent. Highly recommended!
    • For quick reference, I’ve been using the D12 dice roller when testing dice mechanics—clean design and instant results help a lot. It might give you a solid visual template to work from as you build your own games.
    • 🪙 GoldRush — High Five x20 🪙   A fresh High Five server focused on active progression, fair competition, and a healthy player-driven economy.   GoldRush is built for players who want a fresh spin on our beloved game that is connected to today's world via Web3 marketplace.    🏅 Gold Bar & Marketplace • Gold Bars are part of the server's custom economy — they can be used in Marketplace or Cosmetics shop. • Tokens are optional and used only for server Marketplace features.   ⚙️ Server Rates • EXP: 20x • SP: 20x • Adena: 10x • Normal Drop Chance: 8x • Spoil Chance: 12x • Raid Drop Chance: 3x • Quest Item Drop Amount: 5x • Quest EXP/SP Reward: 10x • Quest Adena Reward: 5x   ✨ Enchant Rates • Max Enchant: Weapons +16 / Armors +12 • +0 to +3 armor / weapon = 100% safe • +0 to +4 full body armor = 100% safe • +4 to +6 = 66% • +7 to +9 = 60% • +10 to +12 = 54% • +13 to +14 = 48% • +15 to +16 = 42%   🛒 Alt+B Services GoldRush includes useful Alt+B services: • GM Shop up to Dynasty • Buffer 1h • Teleports • Drop Search • Rankings   🎒 Auto-Loot • Normal mob drops: auto-loot • Adena: auto-loot • Raid drops: stay on the ground • Herbs: stay on the ground   🧙 Class Progression • 1st and 2nd professions are free with shadow weapon reward. • 3rd profession: 5kk • Auto Learn Skills • Subclass - No Quest • Noblesse - Full Quest     ⚔️ Olympiad • Hero period: 1 week • Olympiad time: 18:00–00:00 server time • Match duration: 5 minutes • Max enchant in Olympiad: +6   🏰 Sieges Castle sieges take place on Sundays at 16:00 and 20:00 GMT+3. The first siege will happen 2 weeks after launch.   🐉 Grand Boss Respawn Queen Ant: 24h + 2h random Core: 30h + 2h random Orfen: 48h + 2h random Baium: 120h + 3h random Antharas: 120h + 24h random Valakas: 120h + 24h random Beleth: 120h + 24h random   ⚔️ Fair Play Bots are strictly forbidden and will result in a ban without warning. Dualbox is limited to 1 box. GoldRush is built around a healthy player-to-player economy. Website : https://www.goldrushpvp.xyz/ Discord : https://discord.com/invite/v3zRZVV6ka Guide of how to make an account on our web3 server!  
    • Patch notes of update v1.0 is done regarding some feedbacks. Added Special Buffs category to the buffer. Queen Cat, Seraphim and Dwarf equipment buffs are now available. Special buffs last 1 hour and can be saved in schemes. Players can now Shift+Click monsters to check drops and spoil directly in-game.
  • Topics

×
×
  • Create New...

Important Information

This community uses essential cookies to function properly. Non-essential cookies and third-party services are used only with your consent. Read our Privacy Policy and We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue..