How to use  the same channel to send a file and messages to the server

I'm trying to develop a simple program that will send and receive files from the server and in the same time I need to communicate with the server through the messages
I'm using TCP Socket
my problem is
I have only one channel
so, I have no option, either I can use it for sending the file itself or sending the message .. but not both !
my question is : How can I use the same channel for sending and receiving (file & message)
I would appreciate for any clue or hint
best

kajbj wrote:
kmarwani wrote:
Thanks for reply
yes, that what I'm thinking to do
but, in case of sending binary file, if I attached a flag on its header, will it corrupt the file ?
bestThe other end would of course need to decode the messages that you get, and only write the "data" part to the file.Thanks
I'm gonna try to hard-code what you suggest and i will post what happen with me here
even though I'm not sure how can I add header to a binary file and remove it from the file at other end. (coz I read it as stream and send as array without touching its contents)
this how I'm sending the file
ConnSocket = CSocket.accept();
ToClient = new DataOutputStream(ConnSocket.getOutputStream());
File myFile = new File("abc.jpg");
FileInputStream myFileInStream = new FileInputStream(myFile);
BufferedInputStream mybuffInStream = new BufferedInputStream(myFileInStream);
myBytArray = new byte[(int) myFile.length()];
mybuffInStream.read(myBytArray, 0, myBytArray.length);
ToClient.write(myBytArray, 0, myBytArray.length);
ToClient.flush();
myFileInStream.close();best

Similar Messages

  • How to use the same services-config for the local and remote servers.

    My flex project works fine using the below but when I upload my flash file to the server I doesn't work, all the relative paths and files are the same execpt the remote one is a linux server.
    <?xml version="1.0" encoding="UTF-8"?>
    <services-config>
        <services>
            <service id="amfphp-flashremoting-service"
                class="flex.messaging.services.RemotingService"
                messageTypes="flex.messaging.messages.RemotingMessage">
                <destination id="amfphp">
                    <channels>
                        <channel ref="my-amfphp"/>
                    </channels>
                    <properties>
                        <source>*</source>
                    </properties>
                </destination>
            </service>
        </services>
        <channels>
        <channel-definition id="my-amfphp" class="mx.messaging.channels.AMFChannel">
            <endpoint uri="http://localhost/domainn.org/amfphp/gateway.php" class="flex.messaging.endpoints.AMFEndpoint"/>
        </channel-definition>
        </channels>
    </services-config>
    I think the problem  is the line
            <endpoint uri="http://localhost/domainn.org/amfphp/gateway.php" class="flex.messaging.endpoints.AMFEndpoint"/>
    but I'm not sure how to use the same services-config for the local and remote servers.

    paul.williams wrote:
    You are confusing "served from a web-server" with "compiled on a web-server". Served from a web-server means you are downloading a file from the web-server, it does not necessarily mean that the files has been generated / compiled on the server.
    The server.name and server.port tokens are replaced at runtime (ie. on the client when the swf has been downloaded and is running) not compile time (ie. while mxmlc / ant / wet-tier compiler is running). You do not need to compile on the server to take advantage of this.
    Hi Paul,
    In Flex, there is feature that lets developer to put all service-config.xml file configuration information into swf file. with
    -services=path/to/services-config.xml
    IF
    services-config.xml
    have tokens in it and user have not specified additional
    -context-root
    and this swf file is not served from web-app-server (like tomcat for example) than it will not work,
    Flash player have no possible way to replace token values of service-config.xml file durring runtime if that service-config.xml file have been baked into swf file during compilation,
    for example during development you can launch your swf file from your browser with file// protocol and still be able to access blazeDS services if
    -services=path/to/services-config.xml
    have been specified durring compilation.
    I dont know any better way to exmplain this, but in summary there is two places that you can tell swf  about service confogiration,
    1) pass -services=path/to/services-config.xml  parameter to compiler this way you tell swf file up front about all that good stuff,
    or 2) you put that file on the webserver( in this case, yes you should have replacement tokens in that file) and they will be repaced at runtime .

  • How to use the same email address for outgoing email on two iPads?

    How to use the same email address for outgoing email on two iPads?.   My wife and I both use the same email address.  We receive the same incoming email on both iPads but are unable to send email from my wife's iPad.  She is using an iPad 2 and is usng IOS 6.0.1

    Hi Creaturekeeper,
    If you've added the account into the iPad and you are unable to send email from it, then please follow the troubleshooting in the article below.
    Get help with Mail on iPhone, iPad, and iPod touch - Apple Support
    Take care,
    Alex H.

  • How to use the same POWL query for multiple users

    Hello,
    I have defined a POWL query which executes properly. But if I map the same POWL query to 2 portal users and the 2 portal users try to access the same page simultaneously then it gives an error message to one of the users that
    "Query 'ABC' is already open in another session."
    where 'ABC' is the query name.
    Can you please tell me how to use the same POWL query for multiple users ?
    A fast reply would be highly appreciated.
    Thanks and Regards,
    Sandhya

    Batch processing usually involves using actions you have recorded.  In Action you can insert Path that can be used during processing documents.  Path have some size so you may want to only process document that have the same size.  Look in the Actions Palette fly-out menu for insert path.  It inserts|records the current document work path into the action being worked on and when the action is played it inserts the path into the document as the current work path..

  • How to Use the same iview for both KM End User and the KM Administrator

    Hi friends,
    *This is my scenario :* How to Use the same iview for both KM End User and the KM Administrator but with different Context
    Menu Options.
    i followed these steps but im getting same context menu for both KM End User and the KM Administrator .
    Assign the role Content Administrator to the user km_admin. This is needed so that km_admin can change
    the presentation settings for the KM Folder u201EReports_kmFolder‟.
    Now, login with user km_admin. Navigate to the Km Folder reports_kmFolder through Content Administration
    -> Km Content. Click on Details link of the folder reports_kmFolder.
    Go To Settings -> Presentation. Click on the tab u201ESettings for You‟-> Click on button u201ESelect Profile‟.
    Select the radio button corresponding to u201Elayout Set‟, and choose u201EConsumerExplorer‟ from the dropdown.
    Click u201EOK‟.
    Select both the check boxes corresponding to Items Affected as shown above, and click u201ESave‟
    Now, remove the u201ESuper Administrator‟ role from the user km_admin and login with this user.
    How rto resolve this????
    Regards,
    Prasad.

    Hello Prasad,
    Most likely the user km_admin still has system principal roles assigned, even though you removed the Super Admin role, you should check that this user doesn't have any other admin roles, otherwise it will be considered a System Principal user and will therefore still have access to all content. For more information see http://help.sap.com/saphelp_nw70/helpdata/en/19/56f28fbd4e11d5993b00508b6b8b11/frameset.htm
    Try creating a new user with just read access to the content and you should see that it will not be able to make any changes etc.
    Regards,
    Lorcan.

  • How to use the same OC4j server with different port number

    How to use the same OC4j server with different port numbers..?
    I have to OC4J installed on my machine on different hard disk drives....
    I want to be able to run both the server simultaneously..?
    is it possible ..it yes then how..?
    for that i have changed the port number of one server...
    but when i am trying to start the other server with different port number..it says that JVM -Bind already...
    Is there any clues...?
    Nilesh G

    In the config directory:
    default-web-site.xml: Change the port the HTTP listener listens on
    jms.xml: Change the port the JMS service listens on
    rmi.xml: Change the port the ORMI listener listens on.
    Or, you can add another web-site.xml file, and deploy your applications to 1 server, and bind the web applications to the different web sites. This way you only have to deploy your applications to 1 place.
    Rob
    Oracle

  • How to use the updated value in the same update statement

    Hello,
    I just wonder how to use the updated new value of other column in the same udpate statement. I am using Oracle 11.2, and want to update the two columns with one update statement as following:
    create table tb_test (id number(5), tot number(5), mon_tot number(5));
    update tb_test set (tot = 15, mon_tot = tot *15) where id = 1;
    ...I would like to update both tot and mon_tot column, the value of mon_tot shall be determinted by the new value of tot.
    Thanks,
    Edited by: 939569 on 1-Feb-2013 7:00 AM

    Edit: example added
    SQL> create table tb_test
      2  ( id number(5)
      3  , tot number(5)
      4  , mon_tot number generated always as (tot*15) virtual
      5  );
    Table created.
    SQL> insert into tb_test (id, tot) values (1, 5);
    1 row created.
    SQL> select * from tb_test;
            ID        TOT    MON_TOT
             1          5         75
    1 row selected.
    SQL> update tb_test
      2  set    tot = 15
      3  where  id = 1;
    1 row updated.
    SQL> select * from tb_test;
            ID        TOT    MON_TOT
             1         15        225
    1 row selected.

  • I tried to send a mail message to too many addees. when the rejection came back "cannot send message using the server..." the window is too long to be able to see the choices at the bottom of it. how can i see the choices at the bottom of that window?

    I tried to send a mail message to too many addees. when the rejection came back "cannot send message using the server..." the window is too long to be able to see the choices at the bottom of it. how can I see the choices at the bottom of that window?

    I tried to send it through gmail and the acct is  a POP acct
    I'm not concerned about sending to the long address list. I just can't get the email and window that says "cannot send emai using the server..." to go away. The default must be "retry", because although I cannot see the choices at the bottom of the window if I hit return it trys again... and then of course comes back with the very long pop up window that I cannot see the bottom of so I can tell it to quit trying...

  • I can not send my Note through email and it used to work. The same problem to send picture from iPhone message

    Can't send Notes through email and it used to work. The same problem of sending picture from iPhone message. Did the reset twice but still not working

    Try a reset:
    Hold the Sleep and Home button down for about 10 second until you see the Apple logo.

  • I'm looking into how apps use the cloud. Would you consider any app with social media access as uploading information to the cloud? e.g. being able to tweet through an app is the same as uploading data to the cloud

    I'm looking into how apps use the cloud. Would you consider any app with social media access as uploading information to the cloud? e.g. being able to tweet through an app is the same as uploading data to the cloud

    Most of us in this forum are users who volunteer on technical issues, and not Adobe employees although they do drop in from time to time. As users we simply have no control over activation and that's why you are not getting responses.
    If you havn't done so,you might try the Muse forums and see if you can get a staff member to look into it. Have your case numbers and phone transcripts handy.
    Last option is to keep calling customer service until you get someone who will help or ask for a supervisor.
    Hope this get resolved,
    Gene

  • "Cannot send message using the server....."

    Hi all,
    Considering the nature of the problem I am about to relate I would have to say at the outset that I would be very very surprised if other people have not come across this problem, so here goes...
    We have around 60 users of Apple Mail from both 10.4 and 10.5, so varying degrees of versions of Apple Mail however most if not all are updated to 10.4.11 and 10.5.2.
    We have been plagued with people being frustrated about emails bouncing back with an immediate error which is basically the following...
    "Cannot send message using the server smtp.xxx.com:user
    Sending the message content to the server failed.
    Select a different outgoing mail server from the list below etc etc"
    I am sure a lot of you have seen this error.
    However, it is totally random but I am at the end of my tether with it. It generally revolves around emails with attachments and can be totally random. I was trying to send a screenshot today, very small screenshot, using the Apple-Shift-4 technique, sent the .png file, then saved it out as a .jpg, nothing. Tiny file, around 5k. Got the error above, took it out, sent no problem. Other similar files on the desktop refused to send but a .pdf did. I then thought it might be our server, so sent teh same attachments using my .mac account. Same result and failed to send. Reports from other users in our group show that they too get random results, maybe moving the attachment in the email makes it go, sometimes putting it before your signature, sometimes putting your signature copied and pasted in so many times makes it work, all sorts of methods but all resulting in the same conclusion, Apple Mail can be very unreliable.
    We have even migrated some users to Entourage and the problem disappears. Even to Thunderbird, but those users miss the search capability as it is quicker and more reliable. So they want to go back.
    Considering I have been struggling with this issue back in the day when we were on the Apple Mail related version in 10.4 I was hoping that the version released in 10.5 would remedy the problems. Sometimes I feel it has just got worse.
    Is anyone else experiencing this sort of difficulty in Apple Mail, I really feel isolated and at a loss with how to remedy this for so many users.
    If anyone can share their experiences and how they have got around similar issues in Mail I am all ears and open to any suggestions.
    Thanks everyone for taking the time to read through this. There is more but the experiences are so random it is not worth trying to put it all down.
    Thanks again.
    Gerry McCoy

    I went in to Connection Doctor and. oddly enough, for this Mac account it said I was on Port 25. Si I changed it to Port 587 and saved the changes.
    Still, I have the same problem with the same error messages.
    I go back to the mail preferences > Accounts > Advanced and it shows Port 143 still there grayed out.
    What about SSL - it's not checked.
    Odd that this problem only seems to be from one .mac account emailing to another .mac account. Could the server be down?

  • OSX Mail - Cannot send message using the server ....

    Hi there,
    Mac Pro with OSX 10.6.
    *Can receive mail, but can no longer send email* using the program Mail.
    Been getting the popup "Cannot send message using the server [shawmail.vc.shawcable.net] for the past 3 days. I hadn't changed anything about my computer, and have had the Mac for 2+ years. So this just started doing it on it's own.
    I had a technical support guy from my service provider even interface with my computer, where he could see my desktop right over the internet, and he couldn't get it fixed either.
    I googled this problem, and found solutions like:
    1. Uncheck "Use SSL" (Done that, and it was never checked "on" to begin with)
    2. Make sure Authentication is set to none, with no password (done that, and it wasn't set with a password to begin with)
    3. Delete [user]/Library/Preferences/com.apple.mail.plist (done that, didn't do anything)
    4. We even totally deleted my account, and started a new fresh one. Didn't work
    The tech support guy did show me a way to email online, using the same email account. That worked, but it's a hassle to go onto a web-based email program -- it's not my preference. So, with great certainty, it's not my service provider, because I was able to send emails on this web-based email program using my email account.
    So there, I'm stumped.
    Hopefully someone can help. What's bizarre is that googling this problem, I have found many other people that say it happens arbitrarily, out of nowhere.

    I can't believe how ridiculous this issue is. i have been searching for days for a solution to this. i have tried EVERY recommendation on these forums and nothing works. It appears that this issue dates back to TIGER. I had this problem back in January and just bagged figuring it had something to do with iweb. I bought a new html program and was able to send out my newsletter last month no problem. Suddenly, one month later- here i am again, unable to send out my newsletter with no help from Apple or verizon, or these forims, or anyone else. To think that a company that I have stood behind and loved so much can't be be bothered fixing such a simple issue that has been going on now through  5 OS's (I am using Lion but I had the issue using leopard as well)  is a disgrace.

  • How to use the Function module 'BAPI_APPRAISAL_GETDETAIL'

    hello friends,
    I have to create the report which displays appraisee name, appraiser name,reviewer name and result.Using BAPI_APPRAISAL_GETDETAIL we can get the above all.But i don't know how to use the above function module.If anyone have  used in their program could you please send me or anyone have idea how to do that Please help.It is very Urgent Help me.
    Thanks in advance,
    Regards,
    Ashok.

    Hi,
    I do not hae the code but i can tell you how you use the FM and get the required data, please follow the below mentioned steps:
    1) In this Bapi you need to pass the Plan verison and Object Id data in the BAPI Import parameters and while passing the these values need to decalra the data variables same (of use the same reference fields as they are in Bapi import fields)as they are Bapi importing data fields.
    2) decalre the Internal Table structure as they are in the Export and Table parameters.
    3) Assign the decalred Import and Tables structures to the BAPI FM.
    4) once the Bapi is run with the Import parameters data the Apprisal data  and Apprisee data will returened in the import and table structures and also return value wll be imported.
    5) now using the Structures which are in Import and Table decalrations in the FM you can retrieve the data by reading them.
    Do let me know if you need any more details in this regard.
    Raghotham Reddy.
    If you find this is the right solution then allocate reward point.

  • "cannot send email message using the server icloud" on 10.6.8

    I use mail from my desktop, not from iCloud on the Internet. I have a MacBook Pro with 10.6.8 Snow Leopard. My mail was working fine until yesterday.
    It says "Cannot send message using the server iCloud. connections to the server smtp.me.com on the default ports timed out. Select a different outgoing mail server from the list below.
    The list has:
       ICloud offline
       and Icloud
    Neither of them work.
    What has Apple changed regarding this in September?
    (I know others have posted similar message, but they were on 10.7)

    Same problem here.
    Recently an @icloud.com version (alias) of my existing @me.com email address appeared on my account. I can still send messages form the OSX build in Mail client as long as I am using the @me.com version of my email, but I do get this message when I try to use the new @icloud.com account.
    My account with iCloud states that both @me.com and @icloud.com versions of my email are active.
    Would be nice to know if this is a temporary problem of if this is a permanent one.
    The settings on the outgoing mail server are default as retrieved from apple when I configured the @me.com email for the first time. I went through the troubleshooting suggestions as provided on Apple website, double checking all the settings, no joy. At the very list I can still use the old @me.com alias with no problem (for now)
    MacBook Pro / Mountain Lion 10.8.2

  • Cannot send message using the server (null)

    i use mail 2.1.
    i have a .mac account and have three other email accounts attached to my mail account.
    lately, i cannot send any email.
    the switchiing ports fix hasn't helped either.
    this is the error message:
    CANNOT SEND MESSAGE USING THE SERVER (null)
    The server response was: 5.1.0 <email [email protected]>...
    From address does not match authentication.
    Use the pop-up menu below to try a different outgoing mail server. All messages will use this server until you quit Mail or change your network settings.
    Message from: email <[email protected]>
    Send message using: [there is a combo box here with all the four accounts servers listed]
    no matter which one i pick it doesn't work and no email is sent.
    anyone have this error before? or now how to fix it?
    i'd be appreciative.
    thanks
    1.67 GHz Power PC PowerBook G4   Mac OS X (10.4.6)   Sony HDR HC3 HD HandyCam MiniDV

    I was having a similar problem (don't feel like typing all the details)
    I was about to to delete my com.apple.mail.plist, when finally it hit me.
    I ran ethereal (again, I'm sorry, but learning how to use ethereal is a topic unto itself). Following the TCP stream (ie. looking at the smtp messages being sent back and forth) I came across two problems. For some reason my port number was set to 567 or something like that, when it's supposed to be 25, as I had originally set it to.
    Once I corrected the port number I started receiving an error message from the smtp server. It said the return email address could not be authenticated. (using xyz.com as an example) The correct return email address was supposed to be [email protected], but for some reason it was changed to john@xyz in the account settings.
    Anyway, to get to the point, another thing to check is that your return address has been set correctly, and if all else fails, make sure you have X11 installed and use fink to install and run ethereal. This will let you know if you are actually connecting to the server, and will show you any error messages.
    PS. I think this problem started occurring with the last update made to mail. I believe it somehow corrupted my settings. This would explain how my port number could have been changed to the default port number of .mac mail.

Maybe you are looking for