byzxy,Java/C++编程交流群:168424095
面向非连接的Socket通信是基于UDP的。
UDP是User Datagram Protocol的简称,中文名是用户数据包协议,是 OSI 参考模型中一种无连接的传输层协议,提供面向事务的简单不可靠信息传送服务
服务器和客户端进程实现面向非连接的Socket通信的过程及调用的函数
sendto()函数,功能发送数据,函数原型:
int sendto(
SOCKET s, //指定一个Socket句柄
const char* buf,//包含要传输数据的缓冲区
int len,//缓冲区数据的长度,单位字节
int flags,//指定调用函数的方式
const struct sockaddr *to,//指定接收数据的目标地址
int tolen//指定地址长度
);
成功,返回发送数据的字节数,否则返回SOCKET_ERROR
recvfrom()函数,功能接收数据,函数原型
int recvfrom (
SOCKET s, //指定一个Socket句柄
char* buf,//包含要接收数据的缓冲区
int len,//缓冲区数据的长度,单位字节
int flags,//指定调用函数的方式
struct sockaddr *from,//指定发送数据的主机地址
int fromlen//指定地址长度
);
成功,返回接收数据的字节数,否则返回SOCKET_ERROR
)
例子:客户端向服务器发送字符串,服务器接收客户端发过来的字符串。
源码下载:
public static void main(String[] args) throws Exception { String[] command = { "C:\\Program Files (x86)\\EditPlus 3\\EditPlus.exe", "C:\\1.txt" }; Runtime.getRuntime().exec(command ); }
这是用我的电脑上的editplus 打开我c盘上的一个文件。
已有 0 人发表留言,猛击->>这里<<-参与讨论
ITeye推荐
- —软件人才免语言低担保 赴美带薪读研!—
crsctl语法
$./crsctl
Usage: crsctl check crs - checks the viability of the CRS stack
crsctl check cssd - checks the viability of CSS
crsctl check crsd - checks the viability of CRS
crsctl check evmd - checks the viability of EVM
crsctl set css <parameter> <value> - sets a parameter override
crsctl get css <parameter> - gets the value of a CSS parameter
crsctl unset css <parameter> - sets CSS parameter to its default
crsctl query css votedisk - lists the voting disks used by CSS
crsctl add css votedisk <path> - adds a new voting disk
crsctl delete css votedisk <path> - removes a voting disk
crsctl enable crs - enables startup for all CRS daemons
crsctl disable crs - disables startup for all CRS daemons
crsctl start crs - starts all CRS daemons.
crsctl stop crs - stops all CRS daemons. Stops CRS resources in case of cluster.
crsctl start resources - starts CRS resources.
crsctl stop resources - stops CRS resources.
crsctl debug statedump evm - dumps state info for evm objects
crsctl debug statedump crs - dumps state info for crs objects
crsctl debug statedump css - dumps state info for css objects
crsctl debug log css [module:level]{,module:level} ...
- Turns on debugging for CSS
crsctl debug trace css - dumps CSS in-memory tracing cache
crsctl debug log crs [module:level]{,module:level} ...
- Turns on debugging for CRS
crsctl debug trace crs - dumps CRS in-memory tracing cache
crsctl debug log evm [module:level]{,module:level} ...
- Turns on debugging for EVM
crsctl debug trace evm - dumps EVM in-memory tracing cache
crsctl debug log res <resname:level> turns on debugging for resources
crsctl query crs softwareversion [<nodename>] - lists the version of CRS software installed
crsctl query crs activeversion - lists the CRS software operating version
crsctl lsmodules css - lists the CSS modules that can be used for debugging
crsctl lsmodules crs - lists the CRS modules that can be used for debugging
crsctl lsmodules evm - lists the EVM modules that can be used for debugging
If necesary any of these commands can be run with additional tracing by
adding a "trace" argument at the very front.
Example: crsctl trace check css
使用案例
检查crs状态
$ crsctl check crs
CSS appears healthy
CRS appears healthy
EVM appears healthy
检查单个状态
$ crsctl check css
CSS appears healthy
启动crs栈,必须使用root用户
# ./crsctl start crs
Attempting to start CRS stack
The CRS stack will be started shortly
停止crs栈,必须使用root用户
# ./crsctl stop crs
Stopping resources.
Successfully stopped CRS resources
Stopping CSSD.
Shutting down CSS daemon.
Shutdown request successfully issued.
# ./crsctl disable crs
# ./crsctl enable crs
这个命令实际是修改了/etc/oracle/scls_scr/raw/root/crsstart这个文件里的内容。
查看votedisk磁盘位置
$ crsctl query css votedisk
0. 0 /dev/raw/raw2
located 1 votedisk(s).
增加votedisk
# ./crsctl add css votedisk /dev/raw/raw3 -force
Now formatting voting disk: /dev/raw/raw3
successful addition of votedisk /dev/raw/raw3.
删除votedisk
# ./crsctl delete css votedisk /dev/raw/raw4 -force
successful deletion of votedisk /dev/raw/raw4.
关于维护votedisk的相关内容可以查看笔者的如下博客
http://czmmiao.iteye.com/admin/blogs/1758360
查看crs参数
$crsctl get css misscount
60
修改crs参数,必须为root用户
# ./crsctl set css miscount 60
跟踪crs模块,提供辅助功能
CRS由CRS,CSS,EVM三个服务组成,每个服务又是由一系列module组成,crsctl允许对每个module进行跟踪,并把跟踪内容记录到日志中。
$ crsctl lsmodules css
The following are the CSS modules ::
CSSD
COMMCRS
COMMNS
$ crsctl lsmodules evm
The following are the EVM modules ::