socket⽹络编程实训报告java_socket编程实验⼼得体会{
printf("%c||", i + 65);
for (j = 0; j < VERNUM; j++)
if (data[i][j].dis > 0)
printf(" ", j + 65, data[i][j].dis);
printf("\n");
}
PrintRoutData();
getch();
for (i = 0; i < VERNUM; i++)
{
for (m = 0; m < VERNUM; m++)
for (n = 0; n < VERNUM; n++)
data[m][n].flag = 0;
Exchange();
PrintRoutData();
getch();
}
printf("\nexchange the route table:\n");
return 0; }
void welcome() {
php循环语句关键字int gdriver=DETECT,gmode;
registerbgidriver(EGAVGA_driver);
initgraph( &gdriver, &gmode,"C:\Win-TC");
cleardevice();
setbkcolor(CYAN);
setviewport(0,0,639,479,1);
clearviewport();
setbkcolor(BLUE);
setcolor(14);
rectangle(200,200,440,280);
setfillstyle(1,5);java经典上机编程题
floodfill(300,240,14);
settextstyle(0,0,2);
outtextxy(50,30,"Distance Vector Routing Algorithm"); setcolor(15);
settextstyle(1,0,4);
outtextxy(260,214,"Welcome to use!");
line(0,80,640,80);
什么是c语言的常量getch();
delay(300);
cleardevice(); } void InitRoutData(FILE* pfile) {
char num[10];
int i = 0;
char c;
int m, n;
fseek(pfile, 0, 0);
for (m = 0; !feof(pfile) && m < 7; m++)
{
for (n = 0; !feof(pfile) && n < 7; n++)
{
while (!feof(pfile))
{
c = fgetc(pfile);
if (c == ',')
{
num[i] = '\0';
data[m][n].dis = atoi(num);
data[m][n].flag = 0;
data[m][n].flag = 0;
i = 0;
break;
} /*end of if*/
else if ((c >= '0' && c <= '9') || c == '-')
{
num[i++] = c;
} /*end of else if*/
} /*end of while*/
} /*end of for (n = 0*/
} /*end of for (m = 0*/ }
void PrintRoutData() {
int i, j;
for (i = 0; i < VERNUM; i++)
{
settextstyle(1,0,3);
sprintf(tmp," %c",i + 65);
outtextxy(i*80+50,130,tmp);
outtextxy(10,160+i*40,tmp);
}
for (j = 0; j< VERNUM; j++)
{
for (i = 0; i < VERNUM; i++)
{
if (data[i][j].dis <= 0&&i!=j)
{
if(data[i][j].flag2 ==1)
{
setfillstyle(SOLID_FILL,5);
bar(80*i+50,40*j+155,80*i+120,40*j+185); delay(50000);
data[i][j].flag2 =0;
}
setfillstyle(SOLID_FILL,3);
bar(80*i+50,40*j+155,80*i+120,40*j+185); settextstyle(1,0,2);
sprintf(tmp,"-");
outtextxy(80*i+65,40*j+165,tmp);
}
else
if(data[i][j].dis >=0)
{
if(data[i][j].flag2 ==1)
{
setfillstyle(SOLID_FILL,5);
bar(80*i+50,40*j+155,80*i+120,40*j+185);
delay(50000);
data[i][j].flag2 =0;
}
setfillstyle(SOLID_FILL,3);
bar(80*i+50,40*j+155,80*i+120,40*j+185);
settextstyle(1,0,2);
sprintf(tmp,"%d",data[i][j].dis);
outtextxy(80*i+65,40*j+165,tmp);
}
} /*end of for (j = 0*/
} /*end of for (i = 0*/ }
void SendInf(int recv, int send) {
int i;
for (i = 0; i < VERNUM; i++)
{
if (data[send][i].dis > 0&& data[send][i].flag!=1)
{
if (data[recv][i].dis <= 0&&recv!=i)
{
data[recv][i].dis = data[send][i].dis + data[recv][send].dis;
data[recv][i].flag =1;
data[recv][i].flag2 =1;
}
else if (data[recv][i].dis > data[send][i].dis + data[recv][send].dis) {
data[recv][i].dis = data[send][i].dis + data[recv][send].dis;
data[recv][i].flag =1;
data[recv][i].flag2 =1;
linux查看redis表内所有数据}
} /*end of if*/
} /*end of for*/ }
void Exchange() {
int i, j;
自画像油画for (i = 0; i < VERNUM; i++)
{
for (j = 0; j < VERNUM; j++)
{
if (data[i][j].dis > 0&& data[i][j].flag!=1)
{
SendInf(i, j);
} /*end of if*/
} /*end of for (j = 0*/
} /*end of for (i = 0*/ }
四、 实验⼼得体会
通过本次实验训练,我了解了距离⽮量路由算法的基本原理,复习了C语⾔编程的内容,通过对路由算法的实现,加深了对路由表交换的理解。
实验⼆
⼀、 实验⽬的及要求
编写程序,联系Socket编程和TCP/IP协议的应⽤,要求实现Server端和Client端的信息通信。
⼆、实验原理
在TCP/IP编程中,为客户端和服务器端提供相同的端⼝号和IP地址号,实现Server端和Client端互联,运⽤Java⽂件流的知识,实现两端的信息传递。
三、源程序
/********************ChatClient*********************/ import java.awt.*; import java.awt.event.*; import jav
a.io.*; import
java.io.IOException; import java.*;
public class ChatClient extends Frame{
Socket s = null; DataOutputStream dos = null; TextField tf = new TextField(); TextArea ta = new TextArea();
public static void main(String[] args) { new ChatClient().launchFrame(); }
public void launchFrame() { setLocation(400,300); this.setSize(300,300); add(tf,BorderLayout.SOUTH);
add(ta,BorderLayout.NORTH); pack(); tf.addActionListener(new tfListener()); this.addWindowListener(new WindowAdapter() {
public void windowClosing(WindowEvent e) {
disconn();
} }); setVisible(true); conn(); }
public void conn () { try {
linux运维工程师述职报告
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系QQ:729038198,我们将在24小时内删除。
发表评论