-----------------配方(20x ssc)~~-------------
氯化钠3M(175 g/liter)
柠檬酸钠03 M(88 g/liter)
-----------------程序(20x ssc)---------------
3 M NaCl (175 g/liter)
03 M Na3citrate·2H2O (88 g/liter)
Adjust pH to 70 with 1 M HCl
先加3M的氯化钠
再加03M的柠檬酸钠
最后用1M盐酸把pH调整到70
-----------------为什么----------------
用这个可以出来的阿
pH=PKa+log10( [A-]/[HA])
柠檬酸钠:弱酸
氯化钠:共轭碱
弱酸+ 共轭碱= 缓冲剂!~~~
此文件夹不可删除,可以说它是一个像锁链一样把你的F盘与C盘连在一起(- -具体意思不好表达),打个比方:所有电脑外来程序都需要进行注册(就是注册表)不注册用不起来就这样,那么那个文件就像这样只是进行绑定连接如果你想删掉那就格式化就行了,360强力删除也可以试试自己看吧文件或盘子无法读取就不要怪我了
package comkumimhrservertest;
import javanet;
import javanio;
import javaniochannels;
import javaniocharset;
import javaawt;
import javaawtevent;
public class ChatClient {
private SocketChannel sc = null;
private String name = null;
private Frame f;
private TextArea ta;
private TextField tf;
private boolean runnable = true;
public static void main(String[] args){
ChatClient cc = new ChatClient();
cccreateUI();
ccinputName();
ccconnect();
new ReceiveThread(cc,ccgetTextArea())start();
}
public SocketChannel getSc(){
return sc;
}
public void setName(String name){
thisname = name;
}
public TextArea getTextArea(){
return ta;
}
public TextField getTextField(){
return tf;
}
public boolean getRunnable(){
return runnable;
}
public void stop(){
runnable = false;
}
public void shutDown(){
try{
scwrite(ByteBufferwrap("bye"getBytes("UTF-8")));
taappend("Exit in 5 seconds!");
thisstop();
Threadsleep(5000);
scclose();
}catch(Exception e){
eprintStackTrace();
}
Systemexit(0);
}
public void createUI(){
f = new Frame("Client");
ta = new TextArea();
tasetEditable(false);
tf = new TextField();
Button send = new Button("Send");
Panel p = new Panel();
psetLayout(new BorderLayout());
padd(tf,"Center");
padd(send,"East");
fadd(ta,"Center");
fadd(p,"South");
MyClientListener listener = new MyClientListener(this);
sendaddActionListener(listener);
tfaddActionListener(listener);
faddWindowListener(new WindowAdapter(){
public void windowClosing(WindowEvent e){
ChatClientthisshutDown();
}
});
fsetSize(400,400);
fsetLocation(600,0);
fsetVisible(true);
tfrequestFocus();
}
public boolean connect(){
try{
sc = SocketChannelopen();
//"zlg"为目标计算机名
InetSocketAddress isa = new InetSocketAddress("192168143",8814);
scconnect(isa);
scconfigureBlocking(false);
scwrite(ByteBufferwrap(namegetBytes("UTF-8")));
}catch(Exception e){
eprintStackTrace();
}
return true;
}
public void inputName(){
String name = javaxswingJOptionPaneshowInputDialog("Input Your Name:");
thissetName(name);
fsetTitle(name);
}
}
class MyClientListener implements ActionListener{
private ChatClient client;
public MyClientListener(ChatClient client){
thisclient = client;
}
public void actionPerformed(ActionEvent e){
TextField tf = clientgetTextField();
String info = tfgetText();
if(infoequals("bye")){
clientshutDown();
}else{
try{
clientgetSc()write(ByteBufferwrap(infogetBytes("UTF-8")));
}catch (Exception e1) {
e1printStackTrace();
}
}
tfsetText("");
tfrequestFocus();
}
}
class ReceiveThread extends Thread{
private ChatClient client;
private TextArea ta;
public ReceiveThread(ChatClient client,TextArea ta){
thisclient = client;
thista = ta;
}
public void run(){
SocketChannel sc = clientgetSc();
ByteBuffer byteBuffer = ByteBufferallocate(2048);
CharBuffer charBuffer = null;
Charset charset = CharsetforName("UTF-8");
CharsetDecoder decoder = charsetnewDecoder();
String msg = null;
int n = 0;
try{
while(clientgetRunnable()){
n = scread(byteBuffer);
if(n>0){
byteBufferflip();
charBuffer = decoderdecode(byteBuffer);
msg = charBuffertoString();
taappend(msg + "\n");
}
byteBufferclear();
Threadsleep(500);
}
}catch(Exception e){
eprintStackTrace();
Systemexit(0);
}
}
}
import javaio;
import javanio;
import javaniochannels;
import javaniocharset;
import javanet;
import javautil;
public class ICQServer {
private Selector selector = null;
private ServerSocketChannel ssc = null;
//服务器端通信端口号
private int port = 8814;
private Hashtable<String, SocketChannel> userList = null;
public ICQServer() {}
public ICQServer(int port) {
thisport = port;
}
//初始化服务器
public void init() {
try {
//创建选择器对象
selector = Selectoropen();
//创建ServerSocketChannel
ssc = ServerSocketChannelopen();
//设置ServerSocketChannel为非阻塞模式
sscconfigureBlocking(false);
InetAddress ip = InetAddressgetLocalHost();
Systemoutprintln("主机地址 --------> " + ip);
InetSocketAddress isa = new InetSocketAddress(ip, port);
//将与本通道相关的服务器套接字对象绑定到指定地址和端口
sscsocket()bind(isa);
//创建在线用户列表
userList = new Hashtable<String, SocketChannel> ();
}
catch (IOException e) {
Systemoutprintln("初始化服务器时异常,原因 --------> " + egetMessage());
}
}
//启动服务器
public void start() {
try {
//将ServerSocketChannel注册到Selector上,准备接收新连接请求
SelectionKey acceptKey = sscregister(selector, SelectionKeyOP_ACCEPT);
SocketChannel sc;
int n;
String name; //用户名
String msg; //用户发言信息
while (true) {
//选择当前所有处于就绪状态的通道所对应的选择键,并将这些键组成已选择键集
n = selectorselect(); //n为已选择键集中键的个数
if (n > 0) {
//获取此选择器的已选择键集。
Set readyKeys = selectorselectedKeys();
Iterator it = readyKeysiterator();
//遍历当前已选择键集
while (ithasNext()) {
SelectionKey key = (SelectionKey) itnext();
//从当前已选择键集中移除当前键,避免重复处理
itremove();
//如果当前键对应的通道已准备好接受新的套接字连接
if (keyisAcceptable()) {
//获取当前键对应的可选择通道(ServerSocketChannel)
ssc = (ServerSocketChannel) keychannel();
//接收新的套接字连接请求,返回新建的SocketChannel
sc = (SocketChannel) sscaccept();
//如果有新用户接入
if (sc != null) {
//接收新上线用户姓名
name = readMessage(sc);
//设置新建的SocketChannel为非阻塞模式
scconfigureBlocking(false);
//将新建的SocketChannel注册到Selector上,准备进行数据"写" *** 作,
//并将当前用户名以附件的方式附带记录到新建的选择键上。
SelectionKey newKey = scregister(selector,
SelectionKeyOP_WRITE, name);
//将新上线用户信息加入到在线用户列表
userListput(name, sc);
//发送"新用户上线"通知
transmitMessage(name + " in!", "--Server Info--");
}
}
//否则,如果当前键对应的通道已准备好进行"写" *** 作
else if (keyisWritable()) {
//获取当前键对应的可选择通道(SocketChannel)
sc = (SocketChannel) keychannel();
//接收该通道相应用户的发言信息
msg = readMessage(sc);
//获取选择键上附带记录的当前用户名
name = keyattachment()toString();
//如果用户提出要下线
if (msgequals("bye")) {
//从在线用户列表中移除当前用户
userListremove(name);
//注销当前选择键对应的注册关系
keycancel();
//关闭当前可选择通道
scclose();
//发送"用户下线"通知
transmitMessage(name + " out!", "--Server Info--");
}
//否则,如果接收到的用户发言信息非空("")
else if (msglength() > 0) {
//转发用户发言信息
transmitMessage(msg, name);
}
}
}
}
//延时循环,降低服务器端处理负荷
Threadsleep(500);
}
}
catch (Exception e) {
Systemoutprintln("启动服务器时异常,原因 --------> " + egetMessage());
}
}
//转发用户发言信息
public void transmitMessage(String msg, String name) {
try {
ByteBuffer buffer = ByteBufferwrap( (name + ":" + msg)getBytes("UTF-8"));
//将字节数组包装到缓冲区中
Collection channels = userListvalues();
SocketChannel sc;
for (Object o : channels) {
sc = (SocketChannel) o;
scwrite(buffer);
//将缓冲区数据写入聊天面板(TextArea)
bufferflip();
//将缓冲区ByteBuffer的极限值设置为当前数据实际大小,将缓冲区的值设置为0
}
}
catch (Exception e) {
Systemoutprintln("转发用户发言信息时异常,原因 --------> " + egetMessage());
}
}
//接收用户发言信息
public String readMessage(SocketChannel sc) {
String result = null;
int n = 0;
ByteBuffer buf = ByteBufferallocate(1024);
try {
n = scread(buf);
bufflip();
Charset charset = CharsetforName("UTF-8");
CharsetDecoder decoder = charsetnewDecoder();
CharBuffer charBuffer = decoderdecode(buf);
result = charBuffertoString();
}
catch (IOException e) {
Systemoutprintln("接收用户发言信息时异常,原因 --------> " + egetMessage());
}
return result;
}
public static void main(String args[]) {
ICQServer server = new ICQServer();
serverinit();
serverstart();
}
}
以上就是关于请问:ssc 缓冲液的 配方!有谁配置过吗全部的内容,包括:请问:ssc 缓冲液的 配方!有谁配置过吗、$HIDDEN$.ssc是什么文件夹如何删除、Java简单聊天程序等相关内容解答,如果想了解更多相关内容,可以关注我们,你们的支持是我们更新的动力!
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)