¤¢¤Þ¤êHSPSOCK¤Ë¤Ä¤¤¤Æ¤Î¾ðÊ󤬤ʤ¤¤Î¤Ï¡¢Ã桹»È¤¤¾¡¼ê¤¬Æñ¤·¤¤ÅÀ¤¬¤¢¤ë¤è¤¦¤Ç¤¹¤¬¡¢
¥Æ¥¹¥È¤È¤·¤Æ¡¢¥µ¡¼¥Ð¡¼¤È¥¯¥é¥¤¥¢¥ó¥È¤¬¥ê¥¢¥ë¥¿¥¤¥à¤Ë¥Ç¡¼¥¿¤òÁ÷¼õ¿®¤¹¤ë¥³¡¼¥É¤òºî¤Ã¤Æ¤ß¤Þ¤·¤¿¡£
¡¤¿¤À¤·¡¢TCP/IP¤ÎÃ챤¬Å¬Åö¤Ê¤Î¤Ç¡¢¥³¡¼¥É¤ÏÀµ¤·¤¯¤Ê¤¤¤«¤â¤·¤ì¤Þ¤»¤ó¡£
¢¼ÁÌä:¥½¥±¥Ã¥È¤È¥Ý¡¼¥ÈÈÖ¹æ¤Ï¥ï¥ó¥»¥Ã¥È¤Ç¡¢HSPSOCK¤Ç¤Ï32¸Ä¤Î¥½¥±¥Ã¥È¤¬ºîÀ®¤Ç¤¤ë¡Ê32¿ÍÀܳ¤¬¸Â³¦¡Ë¤È¤¤¤¦Íý²ò¤Ç¤è¤¤¤Î¤«
£¼ÁÌä:¥µ¡¼¥Ð¡¼Â¦¤È¥¯¥é¥¤¥¢¥ó¥È¦¤Î¥½¥±¥Ã¥ÈÈÖ¹æ¤È¤¤¤¦¤Î¤Ï°ìÃפµ¤»¤ë¡©ÊÌ¡¹¤Ç¤â¹½¤ï¤Ê¤¤¡©
¤Àܳ¤¹¤ë¿Í¿ô¤¬10¿Í¤Ê¤é¡¢10¸Ä¤Î¥Ý¡¼¥È¤òÍÑ°Õ¤·¤Æ¤¤¤Þ¤¹¤¬¡¢¤½¤¦¤¤¤¦¹Í¤¨Êý¤Ç¤è¤¤¤Î¤«¡£
¥¥Æ¥¹¥È¤Ï¥í¡¼¥«¥ë¥¨¥ê¥¢¤Ç¤·¤«¤Ç¤¤Æ¤¤¤Þ¤»¤ó¤¬¡¢¤³¤Î¥³¡¼¥É¤Ç¡¢¥µ¡¼¥Ð¡¼¤Î¥Ý¡¼¥È³«Êü¤·¤¿¤éÆ°¤¯¤Î¤«
¦¥ê¥¢¥ë¥¿¥¤¥à¥²¡¼¥à¤òÁÛÄꤷ¤Æ¤¤¤Þ¤¹¤¬¡¢¤³¤Î¤è¤¦¤Ê¥³¡¼¥É¤Ç¤è¤¤¤Î¤«
§¼õ¿®¡¦Á÷¿®¥¨¥é¡¼½èÍýÅù¤ÎÃí°ÕÅÀ¤¬¤¢¤ì¤Ð¤´¶µ¼¨¤¯¤À¤µ¤¤¡£
¤¢¤Þ¤ê¥Í¥Ã¥ÈÂÐÀï¥â¥Î¤òHSP¤Ç¸«¤«¤±¤Þ¤»¤ó¤¬¡¢¤ä¤Ã¤Ñ¤ê¥²¡¼¥à¤Ë¸Â¤é¤º¡¢Â¾¿Í¤È·Ò¤¬¤ë¥¢¥×¥êºîÀ®¤¬¤·¤Æ¤ß¤¿¤¤¤Ê¤¡¤È¤¤¤¦¤³¤È¤«¤é¤Î¼ÁÌä¤Ç¤¹¡£
¤è¤í¤·¤¯¤ª´ê¤¤¤¤¤¿¤·¤Þ¤¹¡£Ä¹¡¹¤È¼ºÎ餷¤Þ¤¹¡£
¥µ¡¼¥Ð¡¼Â¦
#include "hspsock.as" //¥µ¡¼¥Ð¡¼¤Îµ¯Æ° port=10000 //º£²ó¤Ïport¡¡10000¡Á10031¤ò»ÈÍÑ ipget title "¥¢¥É¥ì¥¹"+refstr+"¡¡¥Ý¡¼¥È"+port+"¤ÇÀܳ¤òÂԤäƤ¤¤Þ¤¹..." sockmake 0,port if stat : dialog "Socket error": goto *errbye //ÊÑ¿ô½é´ü²½ state=0 //ÂÔ¤Á¼õ¤±¾õÂÖ s_id=1 //½àÈ÷¥½¥±¥Ã¥È¤ÎÈÖ¹æ dim socklist,32 //¥½¥±¥Ã¥È¤Î¾õÂÖ´ÉÍý ;======================================================== ;¥á¥¤¥ó¥ë¡¼¥× *main redraw 0 color 125,0,0 boxf ;======================================================== if state=0{//ºÇ½é¤ÎÀܳÂÔ¤Á sockwait 0 if stat>1 : dialog "server0:Socket error": goto *errbye if stat=0 {//Client¤«¤é¤ÎÀܳÍ׵᤬À®¸ù sockput ""+s_id,0//Client¤Ø¶õ¤¤¤Æ¤¤¤ë¥½¥±¥Ã¥ÈÈÖ¹æ¤òÄÌÃÎ sockclose 0//ºÇ½é¤ÎÀܳÂÔ¤Á´°Î» sockmake s_id,port+s_id//ÄÌÃΤ·¤¿¥½¥±¥Ã¥ÈÈÖ¹æ¤È¿·¤·¤¤¥Ý¡¼¥ÈÈÖ¹æ¤Ç¥½¥±¥Ã¥ÈºîÀ® state=1//¼¡¤Î¥¹¥Æ¥Ã¥×¤Ø } } ;======================================================== if state=1{//³äÅö¤Æ¤¿¥½¥±¥Ã¥È¤ÎÀܳÂÔ¤Á sockwait s_id title "CHK="+stat+"/"+a if stat>1 : dialog "server1:Socket error": goto *errbye if stat=0 {//³ä¤êÅö¤Æ¤¿¥½¥±¥Ã¥È¤Ç¤ÎÀܳ¤ËÀ®¸ù sockput "Àܳ´°Î»"+s_id+":",s_id title "³äÅö¥½¥±¥Ã¥È¤ÎÀܳÂÔ¤Á´°Î»"+s_id socklist(s_id)=1//Àܳ´°Î»¤·¤¿¥½¥±¥Ã¥È¤òµÏ¿ s_id++//¼¡¤Î¶õ¤ÈÖ¹æ¤ò½àÈ÷ sockmake 0,port//ºÆ¤Ó¥½¥±¥Ã¥È0¤ÇÀܳ¤òÂÔ¤Ä state=0//Á°¤Î¥¹¥Æ¥Ã¥×¤Ø } } ;===================== ;Á´¥½¥±¥Ã¥È¤Î¤¦¤Á¡¢Àܳ¤¬´°Î»¤·¤¿¥½¥±¥Ã¥È¤«¤é¼õ¿® ;Á´¥½¥±¥Ã¥È¤Î¤¦¤Á¡¢Àܳ¤¬´°Î»¤·¤¿¥½¥±¥Ã¥È¤ØÁ÷¿® repeat 32 if cnt>0{ if socklist(cnt)=1{ ;¼õ¿® sockcheck cnt if stat=0{ data="" sockget data,64,cnt color 0,0,0 pos 300,cnt*20 mes ""+data } if stat { pos 300,cnt*20 mes ""+cnt+"ÈÖ=client:socket error:"+stat } ;Á÷¿® servertxt="Server¤«¤é"+cnt+"ÈÖ¤ØÁ÷¿®"+timer sockput servertxt,cnt timer++ } } loop ;======================================================== ;¤³¤³¤Ë¥²¡¼¥àÅù¤Î½èÍý¤òµ½Ò redraw 1 await 1000/60 goto *main ;===================== ;¥¨¥é¡¼Åù½ªÎ»½èÍý *errbye sockclose mes "½ªÎ»" stop
¥¯¥é¥¤¥¢¥ó¥È¦
#include "hspsock.as" //ÊÑ¿ô½é´ü²½ adr="192.168.0.4" //¢ª¥µ¡¼¥Ð¡¼¤Î¥¢¥É¥ì¥¹:¼«Ê¬¤Î´Ä¶¤Ë¹ç¤ï¤»¤ÆÊѹ¹ port=10000 //º£²ó¤Ïport¡¡10000¡Á10031¤ò»ÈÍÑ ipget ipaddress=refstr state=0 //¥µ¡¼¥Ð¡¼¤Ø¤ÎÀܳ¾õÂÖ ;======================================================== ;¥á¥¤¥ó¥ë¡¼¥× *main redraw 0 color 255,255,255 boxf ;======================================================== if state=0{//¤Þ¤º¥½¥±¥Ã¥È0¤Ç¥µ¡¼¥Ð¡¼¤Î»ØÄê¥Ý¡¼¥È¤ËÀܳÍ×µá title adr+"¡¢¥Ý¡¼¥È"+port+"¤ËÀܳÃæ..." sockopen 0,adr,port if stat {//Àܳ¤Ç¤¤Ê¤«¤Ã¤¿ title "¥µ¡¼¥Ð¡¼¤ËÀܳ¤Ç¤¤Þ¤»¤ó:socket error"+stat count++ pos 0,0 color 0,0,0 mes "Àܳ¤ò»î¹ÔÃæ"+count+"²óÌÜ" }else{//Àܳ¤Ç¤¤¿ data="" count=0 state=1//¼¡¤Î¥¹¥Æ¥Ã¥×¤Ø } } ;======================================================== if state=1{//0ÈÖ¤ËÀܳ¤Ç¤¤¿¤Î¤Ç¡¢¥µ¡¼¥Ð¡¼¤«¤é³ä¤êÅö¤Æ¤é¤ì¤¿ÈÖ¹æ¤ò¼èÆÀ sockcheck 0 if stat=0{//ÈÖ¹æ¤ò¼èÆÀ ;¥µ¡¼¥Ð¡¼¤«¤é¼õ¿® sockget data,64,0 int_data=int(data) sockopen int_data,adr,port+int_data//¤½¤Î¥½¥±¥Ã¥ÈÈÖ¹æ¤ÇÀܳ if stat {//Àܳ¤Ç¤¤Ê¤«¤Ã¤¿ title "¥½¥±¥Ã¥ÈÈÖ¹æ"+int_data+"¤Ç¥µ¡¼¥Ð¡¼¤ËÀܳ¤Ç¤¤Þ¤»¤ó:socket error:"+stat count++ pos 0,0 color 0,0,0 mes "Àܳ¤ò»î¹ÔÃæ"+count+"²óÌÜ" }else{//Àܳ¤Ç¤¤¿ title "Server"+adr+"¡¢¥Ý¡¼¥È"+(port+int_data)+"¤ËÀܳ´°Î»" state=2//¼¡¤Î¥¹¥Æ¥Ã¥×¤Ø } } if stat :pos 0,0: mes "sockget_error"+stat } ;======================================================== if state=2{//³ä¤êÅö¤Æ¤é¤ì¤¿¥½¥±¥Ã¥È¤Ç¥µ¡¼¥Ð¡¼¤È¥Ç¡¼¥¿¤ÎÁ÷¼õ¿® ;¥µ¡¼¥Ð¡¼¤«¤é¼õ¿® sockcheck int_data if stat=0{ sockget data,64,int_data pos 0,30 color 0,0,0 mes "¼õ¿®:"+data } ;¥µ¡¼¥Ð¡¼¤ØÁ÷¿® sockput ""+int_data+"ÈÖClient¤«¤é¼õ¿®:"+timer,int_data timer++ } ;======================================================== ;¤³¤³¤Ë¥²¡¼¥àÅù¤Î½èÍý¤òµ½Ò pos 0,50 color 0,0,0 mes "Client¤ÎIP¥¢¥É¥ì¥¹"+ipaddress redraw 1 await 1000/60 goto *main ;===================== ;¥¨¥é¡¼Åù½ªÎ»½èÍý *bye sockclose¡¡;¥½¥±¥Ã¥È¤òÊĤ¸¤ë redraw 1 await 1000/60 stop