4 Replies - 749 Views - Last Post: 11 June 2012 - 03:22 AM Rate Topic: -----

#1 fancyoso  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 3
  • Joined: 02-June 12

send a .wav from flash to a c# socket

Posted 02 June 2012 - 05:48 AM

hi,
i'm working on a project involving a flash application that has to send a .wav file to a c# socket.

the most recent hint i got was to try it with WCF, but i'm still hoping there might be a very easy solution to problem

right now we are recording something from the microphone, convert it to .wav and send it as a byte-array. the c# server recognizes the connection, but the bytearray has a size of zero. if i try the same with a c# client, it works. it also works, when i save the .wav file with the as3-client and let my server read it from the harddrive (which is obviously not a solution for a client-server system).

i would be grateful for any ideas. if somebody has experience with this, i could post the code if it would help

Is This A Good Question/Topic? 0
  • +

Replies To: send a .wav from flash to a c# socket

#2 Skydiver  Icon User is offline

  • Code herder
  • member icon

Reputation: 3553
  • View blog
  • Posts: 11,014
  • Joined: 05-May 12

Re: send a .wav from flash to a c# socket

Posted 03 June 2012 - 08:07 PM

By "send a .wav file to a c# socket", do you mean:
a) Send a .wav file's contents to a C# web service?
B) Send a .wav file's contents to a server running a service written in C# that is listening on a particular port for a TCP connection?

When you talk about sockets, it almost sounds like you are talking about B, but your mention of the use of bytearray makes me think you really mean A.

Can you explain in more detail how the server works, and what you are trying to do? You obviously are writing a client, but can you also write new code, or modify the existing code on the server?
Was This Post Helpful? 0
  • +
  • -

#3 fancyoso  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 3
  • Joined: 02-June 12

Re: send a .wav from flash to a c# socket

Posted 06 June 2012 - 03:45 AM

Well it seems we kind of do both.
The Flash-Client sends a bytearray to a socket with a particular port using a TCP connection.

We are programming both, the Flash-Client and the C#-Server, ourselves. So yes we can modify the code in any way.

This is the relevant part of the server:
http://nopaste.info/a6e2f2bf73.html

If i send a .wav-file from a C# client (as a bytearray) to this server, this code converts it back and saves the file.
So I'm still hoping, that there is a very quick solution to this problem and we have the right approach.
But if it would make the thing easier, we could wrap the file differently on the client end as well. Or use another kind of connection (if AS3 offers that).

All that matters is to fix this problem as soon as possible. This really wasn't the part of the project where i thought I'd lose much time over.
Was This Post Helpful? 0
  • +
  • -

#4 Skydiver  Icon User is offline

  • Code herder
  • member icon

Reputation: 3553
  • View blog
  • Posts: 11,014
  • Joined: 05-May 12

Re: send a .wav from flash to a c# socket

Posted 06 June 2012 - 04:18 AM

Based on what I see in that pastebin link, the server is expecting to see a stream of bytes arriving. It isn't expecting to see a byte array.

That would mean that your Flash app should open a stream and just send the bytes up. Based on your post #1 you said that the bytearray has a size of zero. I assume you've set a breakpoint both on the sender and the receiver to make sure that the sender truly is sending out X number of bytes, and that your stream read is actually getting those X bytes.

I'll ask the obvious: in your flash application, did you remember to call flush() and close()?

This post has been edited by Skydiver: 06 June 2012 - 04:40 AM

Was This Post Helpful? 0
  • +
  • -

#5 fancyoso  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 3
  • Joined: 02-June 12

Re: send a .wav from flash to a c# socket

Posted 11 June 2012 - 03:22 AM

i solved it :)
i found a chat-programme online, which used flash/c# and did exactly what i needed.

right now my laptop lacks of an operating system, bit i'll try to post commented code tonight, for everybody who might stumble upon this thread

thanks skydiver for your help!
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1