Argument count mismatch on flash.net::Socket/connect()

无人久伴 提交于 2019-12-24 19:09:15

问题


Hi i am receiving this error "ArgumentError: Error #1063: Argument count mismatch on flash.net::Socket/connect(). Expected 2, got 0.".

I have created a .net tcp server that sends 1 byte of data while reading a file, now the flash client connects but i get this error and i don't receive any data at all.

Why am i getting this error?

Thanks for any replies in advance.

Here is the flash code

import flash.net.Socket


var socket = new Socket("localhost",8888);
socket.connect();
socket.addEventListener(Event.CONNECT, connectHandler);
socket.addEventListener(ProgressEvent.SOCKET_DATA, socketDataHandler);


function connectHandler(evt:Event) {
    trace("connectHandler: " + evt);
}

function socketDataHandler(evt:ProgressEvent) {
trace("socketDataHandler: " + evt);
}

and the code that sends the data using .net is

While True

            Dim netStream As NetworkStream = Me._socket.GetStream

            Dim bytes(1) As Byte

            Dim file As New FileInfo("so-deep.ram2000.mp3")
            Dim inputStream As Stream = file.OpenRead
            Dim length As Integer = file.Length
            'Dim os As New System.IO.FileStream(file.FullName, IO.FileMode.Create)

            Dim bb As Byte
            While length > 0 AndAlso inputStream.Read(bytes, 0, bytes.Length) > -1

                netStream.Write(bytes, 0, bytes.Length)

                length -= bytes.Length

            End While



        End While

回答1:


http://help.adobe.com/en_US/FlashPlatform/reference/actionscript/3/flash/net/Socket.html#connect%28%29

It's hard for a socket to connect to a host if it isn't given hosts adress and a port. :)

Set the two arguments of the connect function properly.

public function connect(host:String, port:int):void

Edit:Funny, taking a second look at it, it should have caught the socket constructor settings... somebody changed the function definition in your version of flash, it seems.



来源:https://stackoverflow.com/questions/7697980/argument-count-mismatch-on-flash-netsocket-connect

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!