javaSocket客户端与C服务端通信
转自:http://hi.baidu.com/ssrt_hanbing/blog/item/62e3b934598eeb82a71e1238.html
通过高低位转换。
package com.commnt;
import java.net.*;
import java.io.*;
public class Client {
public String send(String address, int port, String str) {
OutputStream os = null;
DataInputStream is = null;
String look = "";
Socket socket = null;
try {
socket = new Socket(address, port);
os = socket.getOutputStream();
byte[] phone = new byte[str.length()];
phone = ByteUtil.StringtoBytes(phone, str);
os.write(phone);
os.flush();
is = new DataInputStream(socket.getInputStream());
byte[] phone1 = new byte[str.length()];
is.read(phone1);
String strBype = new String(phone1);
look = strBype.toString();
} catch (UnknownHostException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
} finally {
close(socket, is, os);
}
return look;
}
public void close(Socket socket, DataInputStream is, OutputStream os) {
if (os != null)
try {
os.close();
} catch (IOException e) {
e.printStackTrace();
}
if (is != null)
try {
is.close();
} catch (IOException e) {
e.printStackTrace();
}
if (socket != null)
try {
socket.close();
} catch (IOException e) {
e.printStackTrace();
}
}
}
public class ByteUtil
相关文档:
#include<stdio.h>
#include<math.h>
float x1,x2,disc,p,q;
int main()
{
void greater_than_zero(float,float);
void equal_to_zero(float,float);
void smaller_than_zero(float,float);
float a,b,c;
printf("\ninput a,b,c:");
scanf("%f,%f,%f",&a,&b,&c) ......
/*
思路:递归算法
从开始往后递增地写数字,当前从now值开始,存储的位置从cur开始,
则显然加上,now..n,都是新的组合数,对于每一个,{ 输出之,然后递归,处理 _c(n, cur+1, a, i+1) }
*/
/* 输出1,2,3,..,n的组合数 */
#include <stdio.h>
#include <assert.h>
#include <malloc.h>
void ......
我给大家推荐一个 WIN7 下边的无损分区工具 Acronis Disk Director Suite
Acronis Disk Director Suite 下载地址
http://dl.iplaysoft.com/files/32.html
Acronis Disk Director Suite 注册机下载地址
注册机.rar
实在不放心,觉得注册机有毒的朋友可以使用以下序列号
LS6ZZ-YFQYY-667Z9-5ZQGP-P7WCP
5PRKN-9R4 ......
#include "Stdio.h"
#include "Conio.h"
#include
#define size 81
#define lim 5
#define tstr "ABCDEFGH"
void display(char **p,int i);
void display2(char *p[],int i);
void display3(char (*p)[40],int i);
void testint();
int main(void)
{
testint();
getch();
return 0;
}
test1() ......
网上流传很多C和C# 神话
我听了以后,决定打破这些美丽的神话。。给大家开开眼界,更希望能说明一个神话,。,,
解开我 最神秘的等待
C
程序怎样反编译成
C
语言的程序?
神话:无法反编译的,,只能通过汇编来解释。
详细:
C语言源程序经过编译、优化,得到目标格式,但由目标格式不能 ......