私は、ライセンス認証的なことができるように、ソフトを開発しています。
しかし、ソースコードも書いて、localhostで実行するとできますが、自分と同じネットワーク?
遠くの人とやろうとすると、ソケットエラーが出て、サーバーと通信ができていません。
クライアント側
(ソースコードをそのまま張り付けているのでいらないことも混じっています。)
#include "hspsock.as" title "skyteam サーバーログインライセンス認証" cls picload "set.bmp" mmload "set.wav",1,1 mmplay 1 pos 53,84 mes "まず初めに..." mes "このソフトは、本社サーバーとの通信を行います。" mes "http://www.geocities.jp/umemasu2010/upnpcj/" mes "にてポート開放ソフトをダウンロードしてください。" mes "ポート指定の入力欄で「31415,31416,31419,31421」" mes "を入力してください。" mes "そしてポート開放ソフトは閉じずそのままにしておき" mes "次へボタンを押して下さい。" mes "ソフトが終わり次第開放ソフトを閉じてください。" mes "(危険なため)" mes "また、サーバーは1台のみなので1人分しか処理できません。" mes "放置をするとほかの方が接続できなくなりますので" mes "放置をする場合は、一度ソフトを閉じてください。" mes "通信がかなり不安定なので、ソフトが落ちる可能性があります。" mes "その場合は、再試行して下さい。" mes "" mes "Ver.10.6 mes "skyteam ソフトウェア開発チーム・サーバー管理チーム" button "次へ",*eujs stop *eujs dialog "通信を始めます" sdim cmnd cmnd="あいうえお" ; ; HSPによるTCP/IPサーバー・クライアント通信のスクリプトです。。 ; ソケットを作成して、クライアントに文字列を送信して終わります。 ; このスクリプトは、client.asのスクリプトと対にしてお使いください。 ; あらかじめ、このスクリプトを実行しておき、LAN上の別マシンから ; portにポート番号(変更しなくても可)を設定します。 ; 接続に成功すると、クライアント側に、サーバーのメッセージが文字列 ; として送信されてきます。 ; *incomand cls input cmnd, 500, 22 button"送信",*main stop *main port=31415 ipget mes "IPアドレス:"+refstr mes "ポート"+port+"で接続を待っています..." sockmake 0,port if stat : dialog "Socket error": goto *errbye a=0 repeat sockwait 0 title "CHK="+stat+"/"+a if stat>1 : dialog "Socket error": goto *errbye if stat=0 : break a+ wait 10 loop mes "接続しました。("+refstr+")" wait 100 ; sockput cmnd if stat : dialog "Socket error": goto *errbye mes "["+cmnd+"] を送信しました。" goto *step1 ; *bye sockclose goto *incomand ; サーバーを続ける *errbye sockclose mes "終了" stop *step1 adr="localhost" port=31416 mes adr+"、ポート"+port+"に接続中..." sockopen 0,adr,port if stat=0:goto*nexto1 repeat cls if stat : mes"接続できていません(サーバを起動してください)":wait 1:goto *step1:if stat=0:break wait 6 loop *nexto1 mes "接続しました..." a=0 repeat sockcheck 0 title "CHK="+stat+"/"+a if stat!=0 : break wait 10 cmnd1+ loop cmnd1="" sockget cmnd1,100 if stat : dialog "エラーが発生しました!" : goto *bye mes "サーバーからのメッセージ : "+cmnd1 wait 500 if ( cmnd1 = "ライセンス認証に失敗しました。\n理由:入力されたプロダクトキーをサーバーから見つけられませんでした。\nもう一度ご確認ください。" ) { ; ここでif命令を使っている ; 変数"a"の内容が"0"ならここを実行する goto *matigai2 } else { ; ここでelse命令を使っている ; 変数"a"の内容が"0"でないならここを実行する goto *seikai2 } stop //-------------------------- *seikai2 if ( cmnd1 = "ラライセンス認証に失敗しました。\n理由:入力されたプロダクトキーは既に使用済みです。\nもう一度ご確認ください。" ) { ; ここでif命令を使っている ; 変数"a"の内容が"0"ならここを実行する goto *matigai2 } else { ; ここでelse命令を使っている ; 変数"a"の内容が"0"でないならここを実行する goto *seikai3 } *matigai2 mes "ソフトを終了します" wait 1000 end stop *seikai3 cls sdim cmnd4 cmnd4="ユーザーネーム" ; ; HSPによるTCP/IPサーバー・クライアント通信のスクリプトです。。 ; ソケットを作成して、クライアントに文字列を送信して終わります。 ; このスクリプトは、client.asのスクリプトと対にしてお使いください。 ; あらかじめ、このスクリプトを実行しておき、LAN上の別マシンから ; portにポート番号(変更しなくても可)を設定します。 ; 接続に成功すると、クライアント側に、サーバーのメッセージが文字列 ; として送信されてきます。 ; *incomand1 cls input cmnd4, 500, 22 button"送信",*main8 stop *main8 port=31419 ipget mes "IPアドレス:"+refstr mes "ポート"+port+"で接続を待っています..." sockmake 0,port if stat : dialog "Socket error": goto *errbye a=0 repeat sockwait 0 title "CHK="+stat+"/"+a if stat>1 : dialog "Socket error": goto *errbye if stat=0 : break a+ wait 10 loop mes "接続しました。("+refstr+")" wait 100 ; sockput cmnd4 if stat : dialog "Socket error": goto *errbye mes "["+cmnd4+"] を送信しました。" goto *step56 *step56 adr="localhost" port=31421 mes adr+"、ポート"+port+"に接続中..." sockopen 0,adr,port if stat=0:goto*nexto3 repeat cls if stat : mes"接続できていません(サーバを起動してください)":wait 1:goto *step56:if stat=0:break wait 6 loop *nexto3 mes "接続しました..." a=0 repeat sockcheck 0 title "CHK="+stat+"/"+a if stat!=0 : break wait 10 cmnd1+ loop cmnd1="" sockget cmnd1,100 if stat : dialog "エラーが発生しました!" : goto *bye mes "サーバーからのメッセージ : "+cmnd1 mes "以上で設定が完了です。お疲れさまでした。" wait 500 endサーバー側*start #include "hspsock.as" title "skyteamサーバーライセンス認証" ; ; HSPによるTCP/IPサーバー・クライアント通信のスクリプトです。。 ; TCPサーバーに接続して、サーバーから文字列を取得して終わります。 ; このスクリプトは、server.asのスクリプトと対にしてお使いください。。 ; 変数adrに接続先のIPアドレスを、portにポート番号(変更しなくても可) ; を設定してください。接続に成功すると、サーバー側のメッセージが文字列 ; として送信されてきます。 ; ; このスクリプトは、LAN接続を前提に作成された簡単なモデルです。 ; インターネットなどの、速度が安定しない通信環境や、負荷のかかる ; ホストでは、送受信が遅れた場合などの対処が必要になる場合があります。 ; *adf adr="127.0.0.1" port=31415 mes adr+"、ポート"+port+"に接続中..." sockopen 0,adr,port if stat=0:goto*nexto repeat cls if stat :sockopen 0,adr,port:if stat=0:break wait 6 loop *nexto mes "接続しました..." a=0 repeat sockcheck 0 title "CHK="+stat+"/"+a if stat!=0 : break wait 10 cmnd1+ loop cmnd1="" sockget cmnd1,100 if stat : dialog "エラーが発生しました!" : goto *bye mes "サーバーからのメッセージ : "+cmnd1 *SEARCH_KEYWORD // 複数回検索 (by Kpan) notesel aeh noteload "pro.txt" p1 = aeh x = instr (p1,0,cmnd1) mes x if x = "-1" :goto *matigai :else :goto *seikai stop *seikai notesel aeh2 noteload "notpro.txt" p12 = aeh2 x1 = instr (p12,0,cmnd1) mes x1 if x1 = "-1" :goto *seikai2 :else :goto *matigai2 stop *seikai2 cmnd="ライセンス認証に成功しました。\n次のステップへ進みます。" port=31416 ipget mes "IPアドレス:"+refstr mes "ポート"+port+"で接続を待っています..." sockmake 0,port if stat : dialog "Socket error": goto *errbye1 a=0 repeat sockwait 0 title "CHK="+stat+"/"+a if stat>1 : dialog "Socket error": goto *errbye1 if stat=0 : break a+ wait 10 loop mes "接続しました。("+refstr+")" wait 100 ; sockput cmnd if stat : dialog "Socket error": goto *errbye1 mes "["+cmnd+"] を送信しました。" goto *stjr *errbye1 sockclose mes "終了" stop *stjr cmnd="0" port=31499 ipget mes "IPアドレス:"+refstr mes "ポート"+port+"で接続を待っています..." sockmake 0,port if stat : dialog "Socket error": goto *errbye1 a=0 repeat sockwait 0 title "CHK="+stat+"/"+a if stat>1 : dialog "Socket error": goto *errbye1 if stat=0 : break a+ wait 10 loop mes "接続しました。("+refstr+")" wait 100 ; sockput cmnd if stat : dialog "Socket error": goto *errbye1 mes "["+cmnd+"] を送信しました。" goto *step0 *matigai2 cmnd="ライセンス認証に失敗しました。\n理由:入力されたプロダクトキーは既に使用済みです。\nもう一度ご確認ください。" port=31416 ipget mes "IPアドレス:"+refstr mes "ポート"+port+"で接続を待っています..." sockmake 0,port if stat : dialog "Socket error": goto *errbye2 a=0 repeat sockwait 0 title "CHK="+stat+"/"+a if stat>1 : dialog "Socket error": goto *errbye2 if stat=0 : break a+ wait 10 loop mes "接続しました。("+refstr+")" wait 100 ; sockput cmnd if stat : dialog "Socket error": goto *errbye2 mes "["+cmnd+"] を送信しました。" cmnd="2" port=31499 ipget mes "IPアドレス:"+refstr mes "ポート"+port+"で接続を待っています..." sockmake 0,port if stat : dialog "Socket error": goto *errbye1 a=0 repeat sockwait 0 title "CHK="+stat+"/"+a if stat>1 : dialog "Socket error": goto *errbye1 if stat=0 : break a+ wait 10 loop mes "接続しました。("+refstr+")" wait 100 ; sockput cmnd if stat : dialog "Socket error": goto *errbye1 mes "["+cmnd+"] を送信しました。" goto *start stop *matigai wait 100 cmnd="ライセンス認証に失敗しました。\n理由:入力されたプロダクトキーをサーバーから見つけられませんでした。\nもう一度ご確認ください。" port=31416 ipget mes "IPアドレス:"+refstr mes "ポート"+port+"で接続を待っています..." sockmake 0,port if stat : dialog "Socket error": goto *errbye2 a=0 repeat sockwait 0 title "CHK="+stat+"/"+a if stat>1 : dialog "Socket error": goto *errbye2 if stat=0 : break a+ wait 10 loop mes "接続しました。("+refstr+")" wait 100 ; sockput cmnd if stat : dialog "Socket error": goto *errbye2 mes "["+cmnd+"] を送信しました。" goto *shaes *errbye2 sockclose mes "終了" stop *shaes cmnd="1" port=31499 ipget mes "IPアドレス:"+refstr mes "ポート"+port+"で接続を待っています..." sockmake 0,port if stat : dialog "Socket error": goto *errbye1 a=0 repeat sockwait 0 title "CHK="+stat+"/"+a if stat>1 : dialog "Socket error": goto *errbye1 if stat=0 : break a+ wait 10 loop mes "接続しました。("+refstr+")" wait 100 ; sockput cmnd if stat : dialog "Socket error": goto *errbye1 mes "["+cmnd+"] を送信しました。" goto *start stop *step0 screen 0,640,480 *ad adr="127.0.0.1" port=31419 mes adr+"、ポート"+port+"に接続中..." sockopen 0,adr,port if stat=0:goto*nexto3 repeat cls if stat :sockopen 0,adr,port:if stat=0:break wait 6 loop *nexto3 mes "接続しました..." a=0 repeat sockcheck 0 title "CHK="+stat+"/"+a if stat!=0 : break wait 10 cmnd+ loop cmnd="" sockget cmnd,100 if stat : dialog "エラーが発生しました!" : goto *bye mes "サーバーからのメッセージ : "+cmnd goto *step1 *bye mes"終了" stop *step1 #include "hspinet.as" ; ; ファイルの取得(ループあり) ; netinit if stat : dialog "ネット接続できません。" : end //現バージョン ver = "1" //●●変更して●● url = "https://api.mojang.com/users/profiles/minecraft/" //URL name = ""+cmnd //ファイル名 neturl url netrequest name mes "DOWNLOAD 開始" *main ; 結果待ちのためのループ netexec res if res > 0 : goto *comp if res < 0 : goto *bad await 50 goto *main *bad ; エラー neterror estr mes "ERROR "+estr stop *comp ; 完了 mes "DOWNLOAD 完了" notesel na noteload name p1=na x1=strmid(p1,7,8) x2=strmid(p1,15,4) x3=strmid(p1,19,4) x4=strmid(p1,23,4) x5=strmid(p1,27,12) mes x5 notesel poaf noteload "whitelist.json" af=noteinfo(0) ws= "\"name\": \""+cmnd re=" {\n \"uuid\": \""+x1+"-"+x2+"-"+x3+"-"+x4+"-"+x5+"\",\n \"name\": \""+cmnd+"\"\n }," noteadd re,af-1 notesave "whitelist.json" //---------------------------------- *s noteload "notpro.txt" noteadd cmnd1 notesave "notpro.txt" cmnd="ユーザーの登録に成功しました。ユーザー名の変更がありましたらユーザー名変更ツールをご利用ください。" port=31421 ipget mes "IPアドレス:"+refstr mes "ポート"+port+"で接続を待っています..." sockmake 0,port if stat : dialog "Socket error": goto *errbye1 a=0 repeat sockwait 0 title "CHK="+stat+"/"+a if stat>1 : dialog "Socket error": goto *errbye1 if stat=0 : break a+ wait 10 loop mes "接続しました。("+refstr+")" wait 100 ; sockput cmnd if stat : dialog "Socket error": goto *errbye1 mes "["+cmnd+"] を送信しました。" exec "main.exe" endです。