Jump to content
Sign in to follow this  
ZeraKakkade

Add some objects and activate ports

Recommended Posts

Hi,

Sry for my bad english but i have two questions. I hope it is readable.

It would e nice if i get a helpful answer^-^

FIRST QUESTION "Can i add some Models/Objects":

I want to make some 3D Monsters with a ModelEditor or other Programms.

I dunno fileformat (.xxx) at the moment.

But could i add this 3d animated Monstr in a Window like:

$mainfenster = GUICreate("Minion",300,500) ?

i have Search for commands to do this but i haveĀ“nt found one.

If yes:

How can i add this 3d Monster to show it at this Window?

_________________________________________________________________

SECOND QUESTION "ACTIVATE PORTS LIKE SKYPE OR MSN":

I have start the 2 Example files "TCPSend" and "TCPRecv" |Scroll down for Code|

I want edit it for my own Work but i have a Problem:

All my Friend can send Messages to my but i cant write o my friends(no connection)

My Pc has a dynamic IP Adress and a direct connection to the Internet... my intern and extern ports are open.

But if my friends start the Programm Then they can activate her intern ports and nothing more...

But its not usefull to open the Externports manuel or with a other programm.

Skype or Msn or ICQ do it automatically.

How can i chance the code do aktivate the extern ports automatically if i start the programm?

_________________________________________________________________

TCPSend

;CLIENT! Start Me after starting the SERVER!!!!!!!!!!!!!!!
; see TCPRecv example
#include <GUIConstants.au3>

; Start The TCP Services
;==============================================
TCPStartUp()

; Set Some reusable info
;--------------------------
Dim $szServerPC = @ComputerName
; Set $szIPADDRESS to wherever the SERVER is. We will change a PC name into an IP Address
Dim $szIPADDRESS = TCPNameToIP($szServerPC)
Dim $nPORT = 33891


; Initialize a variable to represent a connection
;==============================================
Dim $ConnectedSocket = -1


;Attempt to connect to SERVER at its IP and PORT 33891
;=======================================================
$ConnectedSocket = TCPConnect($szIPADDRESS,$nPORT)


Dim $szData

; If there is an error... show it
If @error Then
    MsgBox(4112,"Error","TCPConnect failed with WSA error: " & @error)
; If there is no error loop an inputbox for data
;   to send to the SERVER.
Else
;Loop forever asking for data to send to the SERVER
    While 1
   ; InputBox for data to transmit
        $szData = InputBox("Data for Server",@LF & @LF & "Enter data to transmit to the SERVER:")
        
   ; If they cancel the InputBox or leave it blank we exit our forever loop
        If @error Or $szData = "" Then ExitLoop
        
   ; We should have data in $szData... lets attempt to send it through our connected socket.
        TCPSend($ConnectedSocket,$szData)
        
   ; If the send failed with @error then the socket has disconnected
   ;----------------------------------------------------------------
        If @error Then ExitLoop
    WEnd
EndIf

TCPRecv

;SERVER!! Start Me First !!!!!!!!!!!!!!!
#include <GUIConstants.au3>

; Set Some reusable info
; Set your Public IP address (@IPAddress1) here.
Dim $szIPADDRESS = @IPAddress1
Dim $nPORT = 33891


; Start The TCP Services
;==============================================
TCPStartUp()

; Create a Listening "SOCKET".
;   Using your IP Address and Port 33891.
;==============================================
$MainSocket = TCPListen($szIPADDRESS, $nPORT)

; If the Socket creation fails, exit.
If $MainSocket = -1 Then Exit


; Create a GUI for messages
;==============================================
Dim $GOOEY = GUICreate("My Server (IP: " & $szIPADDRESS & ")",300,200)
Dim $edit = GUICtrlCreateEdit("",10,10,280,180)
GUISetState()


; Initialize a variable to represent a connection
;==============================================
Dim $ConnectedSocket = -1


;Wait for and Accept a connection
;==============================================
Do
    $ConnectedSocket = TCPAccept($MainSocket)
Until $ConnectedSocket <> -1


; Get IP of client connecting
Dim $szIP_Accepted = SocketToIP($ConnectedSocket)

Dim $msg, $recv
; GUI Message Loop
;==============================================
While 1
   $msg = GUIGetMsg()

; GUI Closed
;--------------------
    If $msg = $GUI_EVENT_CLOSE Then ExitLoop

; Try to receive (up to) 2048 bytes
;----------------------------------------------------------------
    $recv = TCPRecv( $ConnectedSocket, 2048 )

; If the receive failed with @error then the socket has disconnected
;----------------------------------------------------------------
    If @error Then ExitLoop

; Update the edit control with what we have received
;----------------------------------------------------------------
    If $recv <> "" Then GUICtrlSetData($edit, _
            $szIP_Accepted & " > " & $recv & @CRLF & GUICtrlRead($edit))
WEnd


If $ConnectedSocket <> -1 Then TCPCloseSocket( $ConnectedSocket )

TCPShutDown()


; Function to return IP Address from a connected socket.
;----------------------------------------------------------------------
Func SocketToIP($SHOCKET)
    Local $sockaddr = DLLStructCreate("short;ushort;uint;char[8]")

    Local $aRet = DLLCall("Ws2_32.dll","int","getpeername","int",$SHOCKET, _
            "ptr",DLLStructGetPtr($sockaddr),"int_ptr",DLLStructGetSize($sockaddr))
    If Not @error And $aRet[0] = 0 Then
        $aRet = DLLCall("Ws2_32.dll","str","inet_ntoa","int",DLLStructGetData($sockaddr,3))
        If Not @error Then $aRet = $aRet[0]
    Else
        $aRet = 0
    EndIf

    $sockaddr = 0

    Return $aRet
EndFunc

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

×
×
  • Create New...