概述
效果
![](http://o99dg8ap9.bkt.clouddn.com/Socket%E5%A4%9A%E5%AE%A2%E6%88%B7%E7%AB%AF%E7%AE%80%E6%98%93%E7%AD%BE%E5%88%B0%E7%B3%BB%E7%BB%9F.png)
原理和功能
服务器搭建在内网上,通过内网访问实现签到者位置的判断
我这个签到系统没有使用数据库,是将每个人的mac地址和姓名存在数组中,每天签
一次,然后每周可以自动发一封签到数据邮件给维护者
- 以后可以实现数据库,然后扩展更多的功能
服务端代码
服务器主类 MyServer
package qiu;
import java.awt.BorderLayout;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.print.Printable;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.net.ServerSocket;
import java.net.Socket;
import java.util.ArrayList;
import java.util.Calendar;
import java.util.List;
import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JPanel;
import javax.swing.JScrollPane;
import javax.swing.JTextArea;
import javax.swing.JTextField;
/**
* 服务端
* */
public class MyServer extends JFrame{
JTextArea jTextArea =null;//用来显示纯文本的单行区域
JPanel jPanel=null;
JScrollPane jScrollPane =null;
static int num=0;
ServerSocket ss;
/*************************************************/
/*****这里存放签到的人的信息,以后可以直接修改*********/
public String [] name = {
"邱承佳","姜伟","邝遥黔","王浩","刁龙","宋艳","曾诚"
,"文浩轩","陈鑫海","曹兵","江小斐","魏圳辉","李尚","蔡洋","曾玲萍","邱承佳windows",
"丁涛","余旺林","苏相学","黄立民","邓诗洋","宋璐君"};
public String [] mac = {
"c4:54:44:39:e7:d0",//邱承佳
"9C-5C-8E-1B-73-61",//姜伟
"50-7B-9D-CF-A5-FD",//邝遥黔
"1E-E0-10-14-7C-DB",//王浩
"54-EE-75-86-D8-6A",//刁龙
"00-AC-45-41-E6-AB",//宋艳
"34-E6-AD-00-EF-75",//曾诚
"12-A5-89-3E-43-B3",//文浩轩
"F0-DE-F1-70-E8-BE",//陈鑫海
"54-AB-3A-47-16-CC",//曹兵
"80-56-F2-68-7C-CD",//江小斐
"50-7B-9D-83-C8-7F",//魏圳辉
"C8-5B-76-09-4C-F6",//李尚
"30-3A-64-72-73-6B",//蔡洋
"3C-97-0E-D3-FA-E9",//曾玲萍
"08-00-27-D4-59-99",//邱承佳windows
"C4-8E-8F-A7-3E-FD",//丁涛
"B8-2A-72-F1-E3-EF",//余旺林
"40-E2-30-74-16-D2",//苏相学
"34-DE-1A-A7-45-8C",//黄立民
"2E-84-DC-91-58-3F",//邓诗洋
"12-52-CB-77-86-5B"//宋璐君
};
//签到次数
public int [] time={
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0};
//用来记录当天是否签到
public boolean[] isQianDao={
false,false,false,false,false,false,false,false,false,false,false,
false,false,false,false,false,false,false,false,false,false,false,false,false,false,false
,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,
false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,
false,false,