易截截图软件、单文件、免安装、纯绿色、仅160KB

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


相关文档:

通讯录C程序代码

#include <stdio.h>
#include <string.h> /* 程序多次调用biodkey(),应包含头文件bios.h */
#include <bios.h><br>/* 程序多次调用clrscr(),应包含头文件conio.h */
#include <conio.h>
#define MAX 100
#define PAGE 2
#define PRINT1 printf("------------------------------ ......

求方程ax^2+bx+c=0的根(函数)

#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) ......

extern extern “C”

extern是C/C++语言中表明函数和全局变量作用范围(可见性).
它告诉编译器,其声明的函数和变量可以在本模块或其它模块中使用。
1。对于extern变量来说,仅仅是一个变量的声明,其并不是在定义分配内存空间。如果该变量定义多次,会有连接错误
2。通常,在模块的头文件中对本模块提供给其它模块引用的函数和 ......

C 语言二维数组和双重指针

#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() ......
© 2009 ej38.com All Rights Reserved. 关于E健网联系我们 | 站点地图 | 赣ICP备09004571号