package cn.net.test;

import com.google.gson.Gson;

import java.io.DataInputStream;
import java.io.IOException;
import java.net.BindException;
import java.net.ConnectException;
import java.net.SocketTimeoutException;
import java.net.UnknownHostException;
import java.util.Arrays;
import java.util.HashMap;
import java.util.Map;

import cn.net.cpzslibs.prot.SocketCreate;

public class Prot10036 {

//	{
//		"userid": “jymf”,
//		"gender": 1,
//		"age": 1,
//		"profession": “iphoneAPP开发”, 
//		"mobile": “13012345678,
//		}

	public static void main(String[] args) throws BindException, ConnectException, SocketTimeoutException, UnknownHostException, IOException {
		Map<String, Object> map = new HashMap<String, Object>();
		map.put("userid", "jymf");
		map.put("gender", 1);
		map.put("age", 1);
		map.put("profession", "iphoneAPP开发");
		map.put("mobile", "13012345678");
		Gson gson = new Gson();
		String sendJson = gson.toJson(map);
		SocketCreate create = new SocketCreate("192.168.0.46", 8898, "2000000000001");
		create.createJustCreateSocket();
		byte[] sendJsons = sendJson.getBytes("UTF-8");
		
		System.out.println(Arrays.toString(sendJsons));
		
		
//		int jsonlen = sendJsons.length;
//		DataOutputStream dos = create.getDos();
//		dos.write("@JYMF".getBytes("UTF-8"));
//		dos.writeInt(0);
//		dos.writeShort(0);
//		dos.writeShort(10036);
//		dos.writeShort(jsonlen+2);
//		dos.write(sendJsons);
//		dos.writeShort(CRC16Util.CRC16(sendJsons));
		
		
		
		DataInputStream dis = create.getDis();
//		dis.read(b)
		
	}
}
